Skip to content

feat(auth): add OIDC login and access tiers #43

Closed

Description

@uniqueg

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 scopes openid profile email, so no group entitlements are released; an LS Login button image on the login page.
  • Login request: state only; no PKCE and no nonce; the authState cookie isn't deleted after the callback.
  • Tokens: access_token and id_token are set as cookies readable by page scripts (no httpOnly), for 12 h regardless of the token's exp (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?

  1. 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.

  2. 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 nonce next to state. URL-encode all parameters, and delete the state/PKCE cookie after the callback. No implicit or hybrid flows. The client secret stays on the server (env/Secret).

  3. 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.

  4. Tokens in httpOnly cookies (decided): httpOnly, Secure, SameSite=Lax, lifetime from expires_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).

  5. 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.

  6. 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.

  7. Errors: log only the HTTP status and the provider's error field; never codes, secrets or tokens.

  8. Logout: delete Krini's cookies and, if the provider offers end_session_endpoint, end the provider session too.

  9. 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, state and nonce are used; the ID token is validated; no token is readable by page scripts from cookies; cookie lifetime follows expires_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).

Activity

  1. added
    priority: high
    status: in progress
    type: auth
    type: feature
    type: security
    workload: days
    ecp-wp4: M4.4
    on Oct 24, 2026
  2. moved this from Backlog to In progress in ELIXIR On-Cloudon Oct 24, 2026
  3. removed
    type: feature
    type: security
    on Nov 13, 2026
  4. added this to the v0.1.0 milestone on Nov 14, 2026
  5. moved this from In progress to Done in ELIXIR On-Cloudon Nov 15, 2026
  6. removed
    status: in progress
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ecp-wp4: M4.4priority: hightype: authworkload: days

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions