Set up local authentication
Configure a local Keycloak instance for development to enable user authentication for predefined test users.
In this guide
Understand development authentication
Run Keycloak locally
Sign in with test users
Manage test users
Understand development authentication
During development, you need a local authentication provider to test user login, role-based access, and permission systems. The Metadata Capture project includes a pre-configured Keycloak instance with:
- Test realm:
dca-metadata-capture-localconfigured for development - Predefined test users: Users with different roles for testing different access levels
- Role mapping: Roles with permissions that match the application's default configuration
- Client configuration: Ready-to-use OIDC client settings
This local setup mirrors the production authentication flow while providing predictable test data for development.
Run Keycloak locally
The project includes a Docker Compose configuration that starts Keycloak with the development realm pre-configured.
-
Start Keycloak using Docker Compose:
cd e2e/
docker compose -f docker-compose.e2e.yaml up -d keycloak -
Configure authentication environment variables.
Edit the
.envfile in your project to include the following Keycloak connection details:OPENID_CLIENT_ID=dca-metadata-capture-local
OPENID_CLIENT_SECRET=ypctz2GbUYM4qNMg48BRGNfVzgFTINzJ
OPENID_AUTH_URL=http://localhost:8080/realms/dca-metadata-capture-local/protocol/openid-connect/auth
OPENID_TOKEN_URL=http://localhost:8080/realms/dca-metadata-capture-local/protocol/openid-connect/token
OPENID_JWKS_URL=http://localhost:8080/realms/dca-metadata-capture-local/protocol/openid-connect/certs
OPENID_END_SESSION_URL=http://localhost:8080/realms/dca-metadata-capture-local/protocol/openid-connect/logoutThis connects your application to the locally running Keycloak instance.
-
Access the application using the predefined test users.
Sign in with test users
The local Keycloak instance includes predefined test users with different roles and permissions for comprehensive testing. Sign in to the Metadata Capture app locally using the predefined test accounts.
-
Run the app locally at
http://localhost:5173. -
Select Sign in to open the Keycloak login page.
-
Find the list of available test users and their credentials in login-as.ts.
The test user accounts include the following roles:
- Administrator: Full system access and management permissions
- Data Manager: Can create, edit, and manage datasets
- Validator: Can review and validate submitted datasets
- Viewer: Read-only access to published datasets
-
Verify role-based access by logging in with different test users and notice how the application interface changes based on permissions.
Manage test users
Use the Keycloak admin console to modify test users, their roles, and client configurations during development.
-
Open the Keycloadmin console at
http://localhost:8080/admin/. -
Sign in with admin credentials:
- Username: admin
- Password: admin
-
Perform admin tasks for managing test user accounts:
- Manage users: Add, edit, or delete test users
- Configure roles: Modify role assignments and permissions
- Client settings: Adjust OIDC client configuration if needed
- View logs: Monitor authentication events and troubleshoot issues