Advanced Local Development Setup
The dev container is designed to be flexible. While core services like PostgreSQL and NATS run by default, other backing services like identity providers are optional and can be enabled as needed.
This guide explains how to enable and configure the included R-Auth identity provider for local development, allowing you to test authentication and authorization flows.
Setting up a Local Identity Provider (R-Auth)
1. Enable R-Auth Services
The Docker Compose files for R-Auth and its MongoDB database are disabled by default. To enable them, you need to edit the dev container configuration file:
-
Open
.devcontainer/devcontainer.json. -
Find the
dockerComposesection. -
Uncomment the lines for
compose.mongo.ymlandcompose.rauth.yml."dockerCompose": [
"compose.core.yml",
"compose.mongo.yml", // <-- Uncomment this line
"compose.rauth.yml", // <-- Uncomment this line
// ... other services
], -
After saving the file, rebuild your dev container. VS Code should prompt you to do this automatically.
2. Configure R-Auth and Start the Admin BFF
The admin-bff service needs to be started to automatically configure R-Auth and generate the necessary environment variables.
-
Once inside the rebuilt container, run the setup script from the workspace root:
./scripts/start-admin-bff.sh -
This script will:
- Set up the R-Auth instance.
- Create a
.envfile in the project root with the required client IDs and secrets. - The default admin user is
admin@example.comwith the password14CharP@ssword.
Note: If a
.envfile already exists, the script will not run. To re-run the setup, you must first reset the environment.
3. Starting Dependent Services
With R-Auth running and the .env file created, you can now start downstream services that depend on the IdP for authentication.
Starting the IAM Service
The iam-service needs to be seeded with the super admin user ID from the newly created R-Auth instance. The start-iam.sh script handles this automatically.
-
Run the start script for the
iam-service:./scripts/start-iam.sh -
This script reads the
.envfile and executes the database seed command, linking theiam-serviceto the R-Auth super admin.
Starting the Shell App
The shell-app can now be started to log in against the live iam-service and R-Auth IdP.
-
To start the
shell-appconnected to the live backend services:./scripts/start-shell.sh -
The application will be available at
http://localhost:5000. You can now log in using the R-Auth credentials.
Note: Starting a Micro-Frontend (MFE) Once the
shell-appis running, you can start individual micro-frontends. For example, to start theadmin-portal-ui:pnpm --filter=admin-portal-ui startThe admin portal will then be accessible at
http://localhost:5000/adminwithin the shell application after you log in.
4. Resetting the Environment
If you need to start the R-Auth setup process from scratch, you must remove the old .env file and clear the databases for both R-Auth and the iam-service.
-
Reset the R-Auth Database: You need to execute a command inside the
rauth-backendcontainer to drop its database.# 1. Get a shell inside the rauth-backend container
docker exec -it citadel_devcontainer-rauth-backend-1 bash
# 2. Run the cleanup script inside the container
AUTH_SOURCE=admin TEST_MONGO_URI=mongodb://root:changeit@mongo/rauthdb node scripts/cleanup.js -
Reset the IAM Service Database: A helper script is provided to drop and recreate the
iam-servicedatabase schema../scripts/iam/cleanup.sh -
Remove the
.envfile:rm .env
After resetting, you can run scripts again to generate a new configuration.