Skip to content

Replaceable access decision, with a group or entitlement claim rule as default #63

Open

Description

@uniqueg

Is your feature request related to a problem? Please describe.

Hi! With oauth.enable, TESP API checks the token and uses its sub claim (verify_token, token_validator.py L10–L97; settings.toml L11), and #53 adds settings for the accepted issuers and the audience. Per-user access is there already: tasks are stored with the subject as author, and get, list and cancel only touch the caller's tasks (task_endpoints.py L38–L118, task_repository.py L59–L108). What there is no setting for yet is who may use the service in the first place, beyond "anyone with a valid token".

Many providers manage access through groups, released as a claim, e.g., groups (Keycloak) or entitlement values in eduperson_entitlement (e.g., LS Login's entitlement claim, with values like urn:geant:example.org:group:vo:GROUP#example.org and longer values for subgroups). Deployments shared by several institutions often want to admit the members of one group and its subgroups only. Other operators have an authorization regime of their own, or a policy engine they'd like TESP API to ask. So the idea is a small default that works out of the box, with the decision itself kept replaceable.

Describe the solution you'd like

  1. One decision point. The token dependency already runs on every task endpoint. It could return a principal (subject and validated claims) instead of the subject only, and call one function, e.g., check(principal, action, resource), that raises 403 on deny. Actions, e.g., create_task, get_task, list_tasks, cancel_task; the resource, where known, e.g., task ID and author. The author filter stays as it is.

  2. Default: a built-in claim rule, off by default, next to the settings of [WIP] implement oauth fix to not accept tokens from any issuer #53:

    oauth.required_claim.name = "eduperson_entitlement"   # string or list of strings
    oauth.required_claim.values = []     # allowed if a value equals one of these ...
    oauth.required_claim.prefixes = []   # ... or starts with one of these (a group and its subgroups)

    Unset, nothing changes. Some providers release such claims only at the user info endpoint, not in the access token: an optional oauth.required_claim.use_userinfo = true could read the claim there (endpoint from the issuer's discovery document, cached for the token's lifetime).

  3. Optional: an external decision service, off by default:

    oauth.authorizer.url = ""        # empty: built-in rule only
    oauth.authorizer.timeout = 2

    One HTTP call, typically to a sidecar, with principal, action and resource as JSON and an allow/deny answer, so that a policy engine of the operator's choice fits without a dependency in TESP API. When it is set, it decides instead of the built-in rule; if it is unreachable, times out or answers unexpectedly, TESP API denies.

GET /service-info stays public, as it is today.

Done when:

  • The task endpoints call one decision function; the author filter behaves as before.
  • With the claim rule set, tokens without a matching value (exact or prefix) get 403; unset, behaviour is unchanged.
  • GET /service-info stays public.
  • With oauth.authorizer.url set, the external service decides, and TESP API denies when it is unavailable.
  • Tests and the README cover all settings.

The decision function and the built-in rule would be a first pull request; the external call could come with it or later.

Describe alternatives you've considered

  • One client or audience per group at the provider: depends on what the provider supports.
  • A proxy in front of TESP API that checks the claim: every operator has to build and run it.

Additional context

This would fit well after #53. For context: the ELIXIR Node NL (SURF) plans a TESP API deployment with LS Login; we track that in elixir-cloud-aai/generic-issues#106. If this is welcome, we'd be happy to send a PR. And no problem if it doesn't fit your plans.

This issue was written by Claude Code Opus 5.5 on behalf of @uniqueg.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions