This page describes how to configure Stronghold login through GitLab using OIDC. For general information about the method, see OIDC auth method.
GitLab application setup
Go to Settings > Applications of a GitLab user, group, or instance.
Fill out the application name and Redirect URI. Specify one URI per line:
https://stronghold.example.com/ui/stronghold/auth/oidc/oidc/callback http://localhost:8250/oidc/callbackThe first URI is used for web interface login, the second one for CLI login (
d8 stronghold login -method=oidc). If the method is enabled at a different path, replaceoidcin the first URI with that path.Make sure the
openidscope is selected. To pass groups and the username, also selectprofileandemail.Save the application and copy the client Application ID and Secret.
Stronghold setup
Enable the OIDC auth method:
d8 stronghold auth enable oidcBy default, the method is enabled at
auth/oidc/. To use a different path, specify-path.Configure the connection to GitLab. Set
oidc_discovery_urlto the GitLab address without/.well-known/openid-configuration:d8 stronghold write auth/oidc/config oidc_discovery_url="https://gitlab.example.com" oidc_client_id="<Application ID>" oidc_client_secret="<Secret>" default_role="gitlab"The
default_roleparameter sets the role used when no role is specified at login.Create a role. In
allowed_redirect_uris, list the same URIs as in the GitLab application:d8 stronghold write auth/oidc/role/gitlab -<<EOF { "role_type": "oidc", "allowed_redirect_uris": [ "https://stronghold.example.com/ui/stronghold/auth/oidc/oidc/callback", "http://localhost:8250/oidc/callback" ], "oidc_scopes": ["openid", "profile", "email"], "user_claim": "sub", "groups_claim": "groups", "bound_claims": { "groups": ["devops", "security"] }, "token_policies": ["default"], "token_ttl": "1h" } EOFKey role parameters:
Parameter Description allowed_redirect_urisAllowed redirect URIs. They must exactly match the URIs in GitLab. user_claimClaim whose value becomes the entity alias name. For GitLab, you can use subornickname.groups_claimClaim with the list of user groups. The values are used as Identity group alias names. bound_claimsClaims and values that must match for login to succeed. In the example, only members of the devopsorsecuritygroups can log in.oidc_scopesRequested OIDC scopes. token_policies,token_ttlPolicies and TTL of the issued token.
Mapping GitLab groups to Stronghold groups
To assign policies based on GitLab group membership, create external Identity groups and group aliases. For more on external groups, see Identity.
Create an external group with the required policies and save its ID:
d8 stronghold write -field=id identity/group name="gitlab-devops" type="external" policies="devops"Get the accessor of the
oidc/auth method:d8 stronghold auth list -format=json | jq -r '."oidc/".accessor'Create a group alias. The
namevalue must match the group name in thegroupsclaim:d8 stronghold write identity/group-alias name="devops" mount_accessor="<OIDC_ACCESSOR>" canonical_id="<GROUP_ID>"Where
<OIDC_ACCESSOR>is the accessor from the previous step, and<GROUP_ID>is the ID of the external group created in the first step.
On every login and token renewal, Stronghold updates the entity’s external group membership based on GitLab data.
Verifying login
Log in via the CLI:
d8 stronghold login -method=oidc -path=oidc role=gitlabThe CLI opens a browser for GitLab login and receives the response at
http://localhost:8250/oidc/callback.Check the policies and metadata of the issued token:
d8 stronghold token lookupTo verify web interface login, select the OIDC method, specify the
gitlabrole if needed, and complete the GitLab login.
If login fails, check that the redirect URIs match and see the troubleshooting tips in OIDC auth method.