Repository navigation
Description
Why?
Krini must be open to look at, while anything that costs compute is restricted to users with compute access. Users log in with the deployment's OpenID Connect provider (for ELIXIR On-Cloud: LS Login). Krini stays generic: any issuer, any client, any group values, so others can deploy it (ELIXIR On-Cloud has no production network of its own; others should adopt the services).
Current state (rewrite-nextjs at ff1b0a0, src/app/auth/api/*): a server-side Authorization Code flow with a client secret. It works, but:
- Provider hard-wired:
LS_LOGIN_URL+ fixed paths/oidc/authorize|token|userinfo; fixed scopesopenid profile email, so no group entitlements are released; an LS Login button image on the login page. - Login request:
stateonly; no PKCE and nononce; theauthStatecookie isn't deleted after the callback. - Tokens:
access_tokenandid_tokenare set as cookies readable by page scripts (nohttpOnly), for 12 h regardless of the token'sexp(LS Login: 4 h). The ID token is never validated. - Errors: the callback logs more than needed when the token request fails (
callback/route.ts,console.log(err)). - Logout: only deletes the cookies; the provider session stays.
- Access: no tiers yet;
/redirects to/dashboard, there is no guard on pages, and the user's entitlements aren't read.
How?
-
Configuration (runtime env, documented, no defaults for any provider): issuer URL; endpoints via OIDC discovery (
/.well-known/openid-configuration); client ID (and secret, server only); redirect URI; scopes (e.g. add the scope that releases group entitlements); the claim that carries groups (e.g.eduperson_entitlement) and whether to read it from userinfo; the compute and admin group values (exact match plus an optional prefix for subgroups); login button label. LS Login values go into the deployment docs, not the code. -
Flow (decided): keep the confidential client with the code exchange on the Next.js server, as now, and add PKCE (S256), which RFC 9700 recommends for confidential clients too, plus
noncenext tostate. URL-encode all parameters, and delete thestate/PKCE cookie after the callback. No implicit or hybrid flows. The client secret stays on the server (env/Secret). -
Validate the ID token (issuer, audience = client ID, signature via JWKS,
exp,nonce); use it only for Krini's own session, never send it to an API. -
Tokens in
httpOnlycookies (decided):httpOnly,Secure,SameSite=Lax, lifetime fromexpires_in; page scripts never read tokens from cookies. The Cloud Components get the access token through a same-origin route (feat(auth): send the user's token to services #44). -
Groups: read the group claim from userinfo with the access token (the token itself carries no groups at LS Login), cache it for ≤ 5 minutes, and derive the tier.
-
Tiers:
Visitor Can do anonymous browse services and service info (feat: browse services from a registry #40), docs; no login prompt for browsing logged in, without compute access the above, plus "request compute access" (feat(auth): link to a compute access request #45) compute group (or subgroup) the above, plus run tasks and workflows and see their own admin group the above, plus admin views (later, e.g. all users' tasks at a gateway, which proTES shows to its admins) The UI hides or disables actions per tier, but the services enforce access; Krini's tiers are only for display. Derive the admin tier now (configured admin group, shown as the user's tier), so later admin views only need the pages; no admin functions in this issue.
-
Errors: log only the HTTP status and the provider's
errorfield; never codes, secrets or tokens. -
Logout: delete Krini's cookies and, if the provider offers
end_session_endpoint, end the provider session too. -
Show the logged-in user and their tier.
Acceptance criteria
- Anonymous visitors can browse all read-only pages without being asked to log in.
- Login works with any OIDC provider given issuer, client ID and scopes; nothing provider-specific in the code (tested against a mock provider).
- PKCE,
stateandnonceare used; the ID token is validated; no token is readable by page scripts from cookies; cookie lifetime followsexpires_in. - Users in the compute group see run actions; others don't. Non-members see the access request entry point. Members of the admin group are shown as admins.
- No secret, code or token appears in logs.
Dependencies: none. Deployment: register Krini's client (elixir-cloud-aai/generic-issues#48) (redirect URIs for production and http://localhost:3000), and list Krini's client ID in the audience (or client allowlist) of every service that accepts Krini's tokens (registry for writes, gateway, WES services).
Successor of elixir-cloud-aai/tes-dashboard#33 (the TES Dashboard is retired in favour of Krini).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs: fix findings of the automated review