Skip to content

feat: use self-minted tokens for sessions#1249

Merged
leafty merged 47 commits intobuild/feat-self-mint-tokensfrom
leafty/feat-self-mint-tokens
Apr 21, 2026
Merged

feat: use self-minted tokens for sessions#1249
leafty merged 47 commits intobuild/feat-self-mint-tokensfrom
leafty/feat-self-mint-tokens

Conversation

@leafty
Copy link
Copy Markdown
Member

@leafty leafty commented Mar 31, 2026

Use self-minted tokens for sessions.

Details:

  • git-proxy: use internal access and refresh tokens
  • remote-session-controller: use internal access and refresh tokens
  • csi-rclone: use internal refresh tokens with long expiry (24 hours)
    • the POST /api/data/oauth2/connections/:connection_id/token_endpoint API endpoint is updated to support only internal refresh tokens

PR Stack:

@leafty leafty changed the base branch from main to leafty/feat-self-mint-authenticator April 10, 2026 07:19
leafty and others added 7 commits April 10, 2026 07:21
…tor' into leafty/feat-self-mint-tokens

# Conflicts:
#	bases/renku_data_services/data_api/app.py
#	bases/renku_data_services/data_api/dependencies.py
#	components/renku_data_services/app_config/config.py
#	components/renku_data_services/authn/api/api.spec.yaml
#	components/renku_data_services/authn/api/apispec.py
#	components/renku_data_services/authn/api/blueprints.py
#	components/renku_data_services/authn/renku.py
#	test/components/renku_data_services/authn/test_renku.py
Co-authored-by: Samuel Gaist <samuel.gaist@idiap.ch>
Co-authored-by: Samuel Gaist <samuel.gaist@idiap.ch>
leafty added 4 commits April 13, 2026 11:57
Details:
* Add the `RenkuSelfAuthenticator` class which authenticates internal tokens. (This is a new `authenticator`).
* Add the `RenkuSelfTokenMint` class which can create internal tokens. Tokens are signed with the `HS512` algorithm.
* Add the `POST /api/data/internal/authentication/token` endpoint to renew internal tokens. This endpoint has the same OpenAPI definition as `POST /api/data/oauth2/connections/:connection_id/token_endpoint`.
OAuth 2.0 token endpoint to support applications running in sessions
* Update the `pyjwt` dependency.

Note: the next PRs will make use of the new internal tokens for `git-proxy`, `remote-session-controller` and `csi-rclone`.
Base automatically changed from leafty/feat-self-mint-authenticator to build/feat-self-mint-tokens April 14, 2026 09:55
leafty added 4 commits April 15, 2026 06:43
…o leafty/feat-self-mint-tokens

# Conflicts:
#	components/renku_data_services/app_config/config.py
#	components/renku_data_services/authn/api/apispec.py
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 15, 2026

Coverage Report for CI Build 24511689261

Warning

No base build found for commit d370f20 on build/feat-self-mint-tokens.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 86.505%

Details

  • Patch coverage: 32 uncovered changes across 5 files (40 of 72 lines covered, 55.56%).

Uncovered Changes

File Changed Covered %
components/renku_data_services/connected_services/core.py 16 3 18.75%
components/renku_data_services/notebooks/data_sources.py 14 5 35.71%
components/renku_data_services/notebooks/core_sessions.py 7 3 42.86%
components/renku_data_services/authn/chained.py 20 17 85.0%
components/renku_data_services/notebooks/api/amalthea_patches/git_proxy.py 7 4 57.14%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 29744
Covered Lines: 25730
Line Coverage: 86.5%
Coverage Strength: 1.51 hits per line

💛 - Coveralls

@leafty leafty force-pushed the build/feat-self-mint-tokens branch from d03cb1d to d370f20 Compare April 15, 2026 11:06
return user

# NOTE: user is not None since there is at least one authenticator in the chain
assert user is not None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a test leftover ?

Otherwise it should be turned into an exception.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I follow: the assert will raise in tests but not in production mode and this assert makes a type assertion: user is None cannot happen, so the fact that nothing runs in production is OK.

Comment thread components/renku_data_services/connected_services/core.py Outdated
Comment thread components/renku_data_services/notebooks/api/amalthea_patches/git_proxy.py Outdated
Comment thread components/renku_data_services/notebooks/core_sessions.py Outdated
leafty and others added 3 commits April 16, 2026 14:54
@leafty leafty requested a review from sgaist April 16, 2026 13:01
Copy link
Copy Markdown
Member

@olevski olevski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change but we can live without that also. Up to you if you want to use it or not.

class ChainedAuthenticator(Authenticator[AnyAPIUser]):
"""Chain authenticators until a user is authenticated or all authenticators are tried."""

token_field: str = "__not_used__"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should also never be changed here, right? And remember to import Final from typing and field from dataclasses

Suggested change
token_field: str = "__not_used__"
token_field: Final[str] = field(default="__not_used__", init=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...not sure if init=False makes it a bit too weird. Like it is a child of Authenticator but the API is now different. Maybe that is too much. And just Final is enough.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of the field is never used, so it doesn't matter if it is changed. The value is there to indicate that it's not used directly but rather each authenticator in the chain will use its own value.

[dict(id=provider.id, access_token_url=provider.access_token_url) for provider in git_providers]
),
),
client.V1EnvVar(name=f"{prefix}RENKU_AUTHENTICATION_VERSION", value="v2"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's neat. We can handle changes to the internal auth better if there are any in the future.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, though I will probably wipe the old code after a release. 😄

@leafty leafty merged commit de997c2 into build/feat-self-mint-tokens Apr 21, 2026
22 of 24 checks passed
@leafty leafty deleted the leafty/feat-self-mint-tokens branch April 21, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants