Skip to content

Dev UI with OIDC

huwshimi edited this page Jul 26, 2024 · 5 revisions

To be able to log in to the UI with OIDC, both the UI and API need to be accessible on localhost:8000. To do this the UI can be served at localhost:8000 which then proxies the API calls to the backend.

To achieve this the UI and API need to be running in different containers (the UI can also be run from your host machine) to prevent conflicts on port 8000.

Backend

Begin by creating a Multipass container.

Inside that container set up the backend using the development setup instructions.

You will also need to add the oauth client credentials.

Edit the config map:

kubectl edit configmap identity-platform-admin-ui

Enter the values for OAUTH2_CLIENT_ID and OAUTH2_CLIENT_SECRET with the "OAuth2 credentials" founds in LastPass.

Finally restart the deployment:

kubectl rollout restart deployment identity-platform-admin-ui

UI

In another Multipass, or on your host machine check out this repo.

Go to the UI directory:

cd identity-platform-admin-ui/ui/

Install the dependencies:

yarn install

Create a file named .env.local and enter the IP to your Multipass running the backend:

VITE_PROXY_API_URL=http://<backend.ip>:8000/

Now you can run the UI. If you're running the UI locally then you'll need it to be served using port 8000:

yarn dev-serve --port 8000

If you're running the the UI in a Multipass then you don't need to set the port:

yarn dev-serve

To access the UI running inside a Multipass from your host's localhost you can use a SSH port forward:

ssh -L :8000:<multipass.ip>:3000 ubuntu@<multipass.ip>

Now you should be able to visit http://localhost:8000 and log in!

To give yourself privileged access install the FGA CLI and jq:

sudo snap install jq

Set some env vars for store access:

STORE_ID=$(fga --api-url http://127.0.0.1:14457 store list | jq '.stores[0].id' -r)
MODEL_ID=$(fga --api-url http://127.0.0.1:14457 model list --store-id $STORE_ID | jq '.authorization_models[0].id' -r)

Set your user email (you can find out which one is being used here: http://localhost:8000/api/v0/auth/me):

USER_EMAIL=<[email protected]>

fga --api-url http://127.0.0.1:14457 tuple write --model-id $MODEL_ID --store-id $STORE_ID user:$USER_EMAIL admin privileged:superuser

Clone this wiki locally