Configuring CAC Authentication
Background Information
Keycloak supports logging in with an X.509 client certificate if you have configured the server to use mutual SSL authentication. As a result, Keycloak must be configured to use passthrough ingress.
Additionally, Keycloak must be provided with Certificate Authorities (CAs) to trust when verifying client certificates.
Within SmoothGlue, Keycloak can easily be configured to support CAC authentication. Some additional settings must be applied to the realm to enable users to login with their CAC.
Users will only be prompted for their CAC if they have it inserted before visiting the login page. If it is not present when visiting the login page, the user will be prompted for username and password or an error if username and password authentication has been disabled.
Configuring Keycloak for Passthrough Ingress
Enabling the necessary IaC components and resulting bigbang configuration is as simple as toggling this variable in the IaC inputs:
locals {
cluster_inputs = {
sso_passthrough_enable = true
}
}
Enabling CAC Login
These steps are largely the same as Keycloak's documentation with some minor changes, given the format of CAC certificates.
- While you are in the
smoothglue
realm, click onAuthentication
underConfigure
in the left pane. - Select the
browser
flow. - In the top right, select
Action
->Duplicate
.- Name:
Browser CAC Auth
- Description:
Browser based authentication with CAC authentication
- Name:
- Click
Duplicate
. - Click
Add step
. - Search and select
X509/Validate Username Form
. - Click
Add
. - Drag
X509/Validate Username Form
block to be the second block just underCookie
. - In
X509/Validate Username Form
'sRequirement
drop-down, selectAlternative
. - Click on
X509/Validate Username Form
's settings (gear icon) and update the following:- Alias:
CAC Auth
- A regular expression to extract user identity:
CN=(?:.*?)(\d*)(?:,|$)
- A name of user attribute:
DOD_ID
- Check certificate validity: toggle on.
- Alias:
- Click
Save
. - Click
Action
->Bind flow
:- Choose binding type:
Browser flow
- Choose binding type:
- Click
Save
.
Associating Users with CACs
Now that Keycloak can prompt users for their CAC, Keycloak needs to know what user is associated to which CAC.
For each user you want to associate:
- While you are in the
smoothglue
realm, click onUsers
underManage
in the left pane. - Select the desired user.
- Click the
Attributes
tab. - Add an attribute:
- Key:
DOD_ID
- Value: The DOD ID number found on the back of their CAC.
- Key:
- Click
Save
.
Troubleshooting
Users Are Not Being Prompted for Their CAC
There are a few likely causes for this:
- The
Browser flow
authentication flow, created in the steps above, is not bound for thesmoothglue
realm.- Please ensure the authentication flow is bound so that users will be prompted for their CAC.
- User has visited the login page before inserting their CAC.
- Have the user restart their browser or try visiting the login page from an incognito window.
- Custom Keycloak configuration has overwritten settings necessary for CAC authentication.
- Please review the default configuration provided by SmoothGlue and Keycloak documentation to determine what was lost.
- If you are providing a custom Truststore for validating smart cards in addition to CACs:
- Please ensure the custom Truststore also includes the DoD CAs required for CAC authentication.
X509 certificate authentication's failed. Invalid user
This error usually means the user attempted to login with their CAC, and Keycloak was unable to associate it to an account.
Please review their DoD ID and ensure it is set correctly within their user account attributes.