Enforce group-based access controls
What you’ll accomplish
Section titled “What you’ll accomplish”You’ll restrict access to a UDS application so that only users in specific Keycloak groups can authenticate. Users who are not in the required group will be denied — even if they have a valid Keycloak account.
Prerequisites
Section titled “Prerequisites”- UDS Core deployed
- Application deployed as a UDS Package with SSO and Authservice configured (see Protect non-OIDC apps with SSO)
- Relevant Keycloak groups exist — either the built-in platform groups or custom groups you have created
Before you begin
Section titled “Before you begin”UDS Core pre-configures two Keycloak groups:
| Group | Purpose |
|---|---|
/UDS Core/Admin | Platform administrators — full access to Grafana, Keycloak admin console, Alertmanager |
/UDS Core/Auditor | Read-only access to Grafana, log browsing |
Application teams can define their own group paths. Group paths follow Keycloak’s hierarchy notation:
/ParentGroup/ChildGroup— nested groups use/as separator- If a group name itself contains a
/, escape it with~(e.g., a group nameda/bbecomesa~/b)
-
Identify the group path
In the Keycloak admin UI (uds realm), go to Groups and locate the group you want to require. Note the full hierarchical path including any parent groups.
For the built-in platform groups, the paths are:
/UDS Core/Admin/UDS Core/Auditor
-
Add
groups.anyOfto your Package CRIn your application’s Package CR, add a
groups.anyOflist under the relevant SSO client. Users must be a member of at least one of the listed groups to be granted access.package.yaml apiVersion: uds.dev/v1alpha1kind: Packagemetadata:name: httpbinnamespace: httpbinspec:sso:- name: Demo SSOclientId: uds-core-httpbinredirectUris:- "https://protected.uds.dev/login"enableAuthserviceSelector:app: httpbingroups:anyOf:- "/UDS Core/Admin"To allow multiple groups (users in any one of the listed groups are granted access):
groups:anyOf:- "/UDS Core/Admin"- "/MyApp/Operators" -
Apply the Package CR
Terminal window uds zarf tools kubectl apply -f package.yamlThe UDS Operator reconciles the Package CR and updates the Authservice authorization policy to enforce group membership.
Verification
Section titled “Verification”Confirm group-based access is enforced:
Test with an authorized user:
- Log in with a user who is a member of the required group
- Access should be granted to the application
Test with an unauthorized user:
- Log in with a user who is NOT a member of the required group
- Access should be denied with a
403 Forbiddenresponse
Check the Authservice chain configuration:
uds zarf tools kubectl get authorizationpolicy -n <app-namespace>Troubleshooting
Section titled “Troubleshooting”Problem: All users are denied access
Section titled “Problem: All users are denied access”Symptoms: Even users who should have access receive a 403.
Solution: Verify the group path in groups.anyOf is exactly correct:
- Log in to the Keycloak admin UI (uds realm)
- Go to Groups and navigate to the intended group
- Copy the full path including parent groups and leading
/ - Compare it character-for-character with the value in your Package CR — paths are case-sensitive
Problem: Group membership does not match what’s in Keycloak
Section titled “Problem: Group membership does not match what’s in Keycloak”Symptoms: A user is in the group in Keycloak but is still denied access.
Solution: Confirm the user’s group membership is included in the token. This can fail if:
- The user’s group claim is not included in the SSO client’s default scopes — in the Keycloak admin UI, go to Clients → your client → Client Scopes and confirm the
groupsscope is assigned - The token was issued before the user was added to the group (the user needs to log out and log back in)
To inspect the token claims, use the Keycloak Account console at sso.<domain> to view recent tokens, or use a tool like jwt.io to decode a token.
Problem: Group name contains a slash
Section titled “Problem: Group name contains a slash”Symptoms: Group path is not matching even though the group exists.
Solution: If the group name itself contains a / character (not a hierarchy separator), escape it with ~. For example, a group named a/b nested under ParentGroup would be written as /ParentGroup/a~/b.
Related Documentation
Section titled “Related Documentation”- Identity & Authentication concepts — background on platform groups and the SSO model
- Package CR reference — full
groupsfield specification - Protect non-OIDC apps with SSO — required prerequisite for group-based access on apps without native OIDC
Next steps
Section titled “Next steps”These guides and concepts may be useful to explore next: