Protect non-OIDC apps with SSO
What you’ll accomplish
Section titled “What you’ll accomplish”You’ll add SSO protection to an application that has no native OIDC support. Authservice intercepts requests before they reach the application and handles the authentication flow on the application’s behalf — requiring users to log in via Keycloak before they can access the app.
Prerequisites
Section titled “Prerequisites”- UDS Core deployed (Authservice is included by default)
- UDS CLI installed
- Application deployed as a UDS Package
- Application pods labeled with a consistent selector that you control
Before you begin
Section titled “Before you begin”Authservice works by matching a label selector on your application’s pods. When a request comes in, Authservice intercepts it, validates the session, and redirects unauthenticated users to Keycloak. The first redirectUris entry you configure is used to populate the match.prefix hostname and the callback_uri in the Authservice chain.
-
Add
enableAuthserviceSelectorto the Package CRSet the selector to match the labels on your application pods:
package.yaml apiVersion: uds.dev/v1alpha1kind: Packagemetadata:name: httpbinnamespace: httpbinspec:sso:- name: Demo SSO httpbinclientId: uds-core-httpbinredirectUris:- "https://httpbin.uds.dev/login"enableAuthserviceSelector:app: httpbinAuthservice will protect all pods labeled
app: httpbinin thehttpbinnamespace. -
Apply the Package CR
Terminal window uds zarf tools kubectl apply -f package.yamlThe UDS Operator creates a Keycloak client, configures Authservice, and sets up the Istio
RequestAuthenticationandAuthorizationPolicyresources automatically.
-
Use separate SSO clients for different auth rules
If you need different group restrictions or different redirect URIs per service, define multiple SSO clients — one per logical access boundary:
package.yaml apiVersion: uds.dev/v1alpha1kind: Packagemetadata:name: my-appnamespace: my-appspec:sso:- name: Admin ServicesclientId: my-app-adminredirectUris:- "https://admin.example.com/login"enableAuthserviceSelector:app: admingroups:anyOf:- "/UDS Core/Admin"- name: User ServicesclientId: my-app-usersredirectUris:- "https://app.example.com/login"enableAuthserviceSelector:app: usergroups:anyOf:- "/MyApp/Users" -
Apply the Package CR
Terminal window uds zarf tools kubectl apply -f package.yaml
Verification
Section titled “Verification”Confirm Authservice protection is active:
# Check that Authservice pods are runninguds zarf tools kubectl get pods -n authservice -l app.kubernetes.io/name=authservice
# Check that the Authservice chain for your app was createduds zarf tools kubectl get authorizationpolicy -n <app-namespace>End-to-end test:
- Open the application URL in a browser
- You should be redirected to the Keycloak login page
- Log in with valid credentials
- You should be redirected back to the application and see the content
Troubleshooting
Section titled “Troubleshooting”Problem: Package CR is rejected with a redirect URI error
Section titled “Problem: Package CR is rejected with a redirect URI error”Symptoms: kubectl apply fails with an error about invalid redirect URIs.
Solution: The redirect URI must not be a root path. Replace root-path URIs with a specific path:
# Invalid — root path not allowed for Authservice clientsredirectUris: - "https://myapp.example.com/"
# ValidredirectUris: - "https://myapp.example.com/login"Problem: Traffic is blocked with 503 errors in ambient mode
Section titled “Problem: Traffic is blocked with 503 errors in ambient mode”Symptoms: After applying the Package CR with ambient mode, requests to the application return 503.
Solution: Verify that the enableAuthserviceSelector matches both the pod labels AND the spec.selector of the Kubernetes Service for those pods. If the selector matches pod labels but not the service selector, the waypoint proxy is associated with the pods but not the service — traffic through the service is blocked rather than routed through the SSO flow.
# Compare pod labels with service selectoruds zarf tools kubectl get pods -n <app-namespace> --show-labelsuds zarf tools kubectl get service -n <app-namespace> -o yaml | grep -A5 selectorProblem: Prometheus cannot scrape metrics from a protected pod
Section titled “Problem: Prometheus cannot scrape metrics from a protected pod”Symptoms: Prometheus shows scrape errors for a workload that uses enableAuthserviceSelector.
Solution: The monitor[].podSelector (or monitor[].selector) in the Package CR must exactly match the sso[].enableAuthserviceSelector for the protected workload. When these match, the operator creates an authorization exception that allows Prometheus to scrape metrics directly without going through the SSO flow.
spec: monitor: - selector: app: httpbin # Must match enableAuthserviceSelector exactly portName: metrics targetPort: 9090 sso: - name: Demo SSO clientId: uds-core-httpbin redirectUris: - "https://httpbin.uds.dev/login" enableAuthserviceSelector: app: httpbin # Must match monitor selector exactlyRelated Documentation
Section titled “Related Documentation”- Identity & Authentication concepts — background on when to use Authservice vs native SSO
- Authservice repository — upstream configuration reference
- Package CR reference — full SSO and
enableAuthserviceSelectorfield specification
Next steps
Section titled “Next steps”These guides and concepts may be useful to explore next: