Repository navigation
feat(auth): register the Findability Explorer as an OIDC client - #111
Merged
Merged
Conversation
The Findability Explorer at digital-strategy.jorisjonkers.dev signs its users in against this authorization server. Adds the registered client, a FINDABILITY_EXPLORER service permission, and the client_id -> permission mapping that gates the authorize endpoint -- the tribelt shape. The client is confidential (client_secret_basic and client_secret_post) and also requires PKCE, with authorization_code and refresh_token and the default token settings. Redirect is /auth/callback, post-logout redirect is the site root, with the .test variants. The secret comes from auth.clients.findability-explorer.secret, supplied as AUTH_CLIENTS_FINDABILITY_EXPLORER_SECRET, defaulting to findability-explorer-secret for local runs and tests. The explorer reads ROLE_ADMIN from the roles claim and renews its tokens to pick up role changes; the integration tests run the real flow to a code and show a promotion made after sign-in in the refreshed ID token. No migration: FINDABILITY_EXPLORER fits user_service_permissions.service VARCHAR(50), which has no check constraint.
…supplied The grimoire shape: auth.clients.findability-explorer.secret has no default, and the client is not registered for a blank secret or the <no value> a Vault template renders while the key is unprovisioned, so production never carries a client with a guessable secret. The integration test base supplies a secret, as it does for grimoire.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Registers
findability-exploreras a confidential OIDC client that also requires PKCE, for the Findability Explorer at digital-strategy.jorisjonkers.dev. The tribelt shape.ServicePermission.FINDABILITY_EXPLORER("digital-strategy"). ID tokens carrySERVICE_FINDABILITY_EXPLORERfor grantees, and for ADMIN as usual.buildFindabilityExplorerClient()(its own file, asServiceRegisteredClients.ktis at detekt's function limit): authorization_code + refresh_token, client_secret_basic/post, PKCE required, no consent, default token settings (15 min access, 7 day refresh, no reuse), scopesopenid profile email. Redirecthttps://digital-strategy.jorisjonkers.dev/auth/callbackand post-logout redirecthttps://digital-strategy.jorisjonkers.dev/, plus the.testvariants."findability-explorer" to ServicePermission.FINDABILITY_EXPLORERinDOWNSTREAM_CLIENT_PERMISSIONS.auth.clients.findability-explorer.secret, supplied asAUTH_CLIENTS_FINDABILITY_EXPLORER_SECRET, and it has no default.findabilityExplorerClientOrNull()registers the client only for a real secret: not for a blank one, and not for the<no value>a Vault template renders while the key is unprovisioned. Until then there is nofindability-explorerclient at all, rather than one with a secret anybody could guess. The integration test base supplies a secret, as it does for grimoire. Local runs get the client only when the property is set.UNPROVISIONED_SECRETis nowinternalso both clients share it.@Valueon theregisteredClientRepositorybean, next to grimoire's. The dash-droppingAUTH_CLIENTS_FINDABILITYEXPLORER_SECRETdoes not resolve the placeholder. I checked both forms against aSystemEnvironmentPropertySource.deploy/auth.project.ymllists the new key undersecret/data/auth-api.Why this shape
The explorer runs its own OIDC flow, so the grant is enforced at the authorize endpoint. Only admins and holders of FINDABILITY_EXPLORER get a code. The app treats
ROLE_ADMINin therolesclaim as its admin role. It keeps the refresh token and renews often to re-read roles, and every issuance reads the user's role and grants from the database, so a change shows up at the next refresh.offline_accessis not a registered scope here: like tribelt, the client gets a refresh token because it holds the refresh_token grant.Mapping the
digital-strategysubdomain means forward-auth, wherever it fronts that host, now also requires FINDABILITY_EXPLORER (or ADMIN). Before this, an unlisted host let every signed-in user through.No migration:
user_service_permissions.serviceis aVARCHAR(50)without a check constraint (FINDABILITY_EXPLORERis 20 characters), and the OpenAPI spec does not enumerate permissions.Deploy prerequisites
auth.clients.findability-explorer.secretinsecret/data/auth-api.AUTH_CLIENTS_FINDABILITY_EXPLORER_SECRETtemplate line. Until the key is provisioned, the client is simply not registered, so this can be released before or after the secret is minted.Verification
./gradlew :api:detektMain :api:detektTest :api:detektIntegrationTest :api:ktlintCheck :api:test :api:integrationTest :api:jacocoTestCoverageVerification :api:exportOpenApiSpec: BUILD SUCCESSFUL. Unit tests 223/223, integration tests 257/257 (Testcontainers), coverage verification passed, no OpenAPI drift.<no value>one.ROLE_USERandSERVICE_FINDABILITY_EXPLORERand a refresh token, then seesROLE_ADMINin the refreshed ID token after a promotion. An admin with no explicit grant signs in. The client is added to the deny, admin-allow and confidential-token-endpoint lists, anddigital-strategyis added to the forward-auth deny list.