External auth with Dex
Use Dex as an OIDC provider for both authentication and authorization to the Gloo UI.
The following instructions are for Linux operating systems. The example uses kind for a demo Kubernetes cluster and Dex for the OIDC provider.
You can follow a similar process for your production setup. After you complete the demonstration steps, continue to the OIDC settings in Helm.
Before you begin
- Make sure that you install the following tools.
- Optional: Review the information about how authentication and authorization work with the Gloo UI.
Create certificates for the OIDC provider
You can test out these steps with a self-signed certificate that uses OpenSSL.
Download the gencerts.sh script.
Optional depending on your file settings: Give the script execution permissions.
Run the script.
The script generates certificates for the OIDC provider in an
ssl
folder, such as in the following example.
Create a demo cluster and set up Dex as your OIDC provider
Set up Dex as the OIDC provider for your Kubernetes cluster. To unify authentication and authorization, the cluster’s OIDC provider must match the provider that you want to use to authenticate to the Gloo UI.
- Download the
kindconfig.yaml
configuration file. Note that the API server is set up with the Dex OIDC information. - Create a Kubernetes cluster locally with the kind configuration file.
- Download the
dex.yaml
configuration file. This configuration file refers to the certificates that you previously generated. It also configures the redirect URLs for accessing the Gloo UI on the local host. - Run Dex as the OIDC provider for your cluster. You can choose to run Dex via a Docker command, or install Dex as a deployment in your cluster via Helm.
Optional: Verify your OIDC setup
You can check that your OIDC setup works by enforcing your kubectl
CLI client to authenticate with Dex.
- To log in to Kubernetes with an OIDC provider and
kubectl
, install the OIDC login plug-in. - Set up the OIDC credentials with the OIDC client information that you previously generated from the script.
- Follow the steps that the plug-in suggests. In particular, add the user’s OIDC access tokens to your
kubectl
config. - Check that your user can view the Kubernetes resources he was granted access to with cluster RBAC rules.
Install Gloo Mesh Gateway and configure the Gloo UI for Dex
The following steps are for a demonstration setup only.
- Install the latest version of
meshctl
. - Install Gloo Mesh Gateway in your kind cluster with the following settings.
- Create a ConfigMap with the root CA.
- Download the
dashboard-settings.yaml
configuration file, to make the Gloo UI use the same OIDC provider and settings as the Kubernetes cluster. Note theuserMapping
section in theDashboard
custom resource matches the cluster settings from thekindconfig.yaml
file that you previously downloaded. For more options, see the API documentation. - Apply the dashboard configuration to your cluster.
- Download the Kubernetes
rbac.yaml
configuration file to give permissions to your OIDC users. Note that the configuration is for one user that matches yourdex.yaml
configuration,admin@example.com
. - Apply the RBAC configuration to your cluster.
Log in to the Gloo UI
Test that authentication and authorization with Dex work in the Gloo UI.
- Open a port on your local machine to access the Gloo UI.
- Open the Gloo UI in your browser: http://localhost:8090.
- Log in to the Gloo UI with your OIDC-provided users,
admin@example.com
oruser@example.com
. The different users have different views, depending on their RBAC permissions.admin@example.com
: This user can authenticate to the Gloo UI. Additionally, the user is authorized to all resources by thecluster-admin
role, as described in therbac.yaml
file.user@example.com
: This user can authenticate to the Gloo UI because the user is in thedex.yaml
OIDC configuration. However, without an RBAC role, the user is not authorized to view any resources in the Gloo UI.
Demo cleanup
To clean up the resources from your local machine, run the following commands.
Debug your demo setup
To troubleshoot connection problems between the OIDC provider and your cluster, review the Kubernetes API server logs.
To check the OIDC token that kubectl
uses, run the following command from the directory where you generated the ssl
folder with the gencerts.sh
script.