Repository navigation
Feat: credential and auth model (tokens, delagation) - #30
Merged
Merged
Conversation
… have them link to each other
…ede into feat/core-contract
…a consumer should choose to use it or not
* feat: Models the core contract needs * Feat: Protocols and Exceptions added for the core contract * Feat: Private protocols for the BatchBackend * feat: a fake backend to run unit tests against * fix: some code cleanup in the helper functions * feat: setup for the unit test suite * chore: style fix * chore: styling, unit test fixture * chore: single letter var `h` refering to hanlde changed to `handle` * fix: unused parameter in `test_injected_failure_is_reported_per_job()` removed * feat: Models the core contract needs * Feat: Protocols and Exceptions added for the core contract * Feat: Private protocols for the BatchBackend * feat: a fake backend to run unit tests against * fix: some code cleanup in the helper functions * feat: setup for the unit test suite * chore: style fix * chore: styling, unit test fixture * chore: single letter var `h` refering to hanlde changed to `handle` * fix: unused parameter in `test_injected_failure_is_reported_per_job()` removed * fix: made the OutputSpec optional as it is not suppoerted by all and a consumer should choose to use it or not --------- Co-authored-by: alexander <alexander.auer@cern.ch>
A value given by mistake, such as a misspelled field or plain data in a CredentialSet, may be the secret itself. Validation errors now hide their input, as the configuration models already do.
The message comes from the consumer's code and may hold a token or a secret URL. The AuthenticationError names only its type; the exception itself is still available as __cause__.
The fields were described in comments, which the generated reference does not show. They now use attribute docstrings, as the configuration models do.
Name every argument and the return value, and drop the blank lines before closing quotes.
Alexander-Auer
marked this pull request as ready for review
October 27, 2026 16:18
Alexander-Auer
added a commit
to Alexander-Auer/intercede
that referenced
this pull request
Oct 27, 2026
… into feat/HTCondorCEBackend Replaces the earlier versions this branch was built on with what was merged upstream (DIRACGrid#27, DIRACGrid#28, DIRACGrid#29) and the credentials under review (DIRACGrid#30). The HTCondor-CE schedd setting moves onto HTCondorCEConfig.
4 tasks
This was referenced Nov 3, 2026
…only allow one credential type instead of combinations
Contributor
Author
|
@aldbr I removed the x509 proxy, so I think it's ready for a review |
aldbr
requested changes
Nov 4, 2026
…n, and removed auth value from config as it was not used
Alexander-Auer
force-pushed
the
stack/credential-models
branch
from
November 16, 2026 08:24
40fcf80 to
11e435b
Compare
aldbr
requested changes
Dec 1, 2026
…ing credentials A backend keeps no credential between operations: it calls provider.get once per operation and checks only the kind and that it has not expired. Whether a token is reused, or one with more scopes is handed out, is the provider's choice. The operation decides a token's scopes and how long it must stay valid (valid_for), defined once in TOKEN_NEEDS.
…s unavailable The audience is the endpoint's host and port in the form each CE checks, with the default port added when the endpoint names none: host:9619 for an HTCondor-CE, https://host:443 for ARC, as DIRAC builds it. The resource stays the endpoint as configured. A provider that raises something untyped now fails the operation with ResourceUnavailableError, which is worth retrying, instead of AuthenticationError, which is kept for a refused or unusable credential.
Submit uploads inputs (compute.modify) and kill and purge read the jobs' states first (compute.read). An SSH transport logs in without knowing the operation, so the operation is optional for the kinds it does not change.
aldbr
reviewed
Dec 1, 2026
transfer_timeout_s bounds collecting one job's output, so the token for it gets the same lifetime instead of a fixed hour; one setting decides both.
…e credential A provider that cannot be reached, holds no credential of the kind asked for, or returns one of another kind or already expired is not the resource rejecting credentials (AuthenticationError) nor the resource being down (ResourceUnavailableError). The protocols now list it next to those two.
aldbr
approved these changes
Dec 1, 2026
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.
feat: credentials (models, provider, freshness)
Part of #17. Follows #29 (merged).
Backends get their credentials from a provider that the consumer owns. Configuration never holds a secret.
A backend authenticates with exactly one credential. X.509 proxies are not supported, so nothing needs a token and a proxy together.
How a consumer uses it
The consumer supplies the credentials: it creates a
CredentialProvider, passes it toget_backend, and closes it when done. interCEde only decides when to ask, never where credentials come from, and never closes the provider.A provider is any object with an async
getmethod andasync withsupport.getreturns one credential, of the kind the backend asks for:For fixed credentials, for example a key read from a file, the consumer can use
StaticCredentialsinstead of writing a provider:One provider can be shared by every backend the consumer drives.
What's added
intercede.auth(public):BearerToken,SSHPrivateKey,SSHPassword. Secrets never appear inrepr, JSON or error messages.CredentialRequirements, which names the onekinda backend needs, and theCredentialProviderprotocol.StaticCredentials. It holds at most one credential of each kind, so it can serve several backends, and each backend gets only the one it asks for. Asking for a kind it does not hold raises anAuthenticationError.authfield only accepts"token".user@host:port, as itsauthfield says.AuthenticationErrorfor the whole operation, never a per-job failure.get_backend(config, credentials)passes the provider to backends and transports. Anything that isn't a provider raises aConfigurationError. Building a backend never calls the provider.Breaking change
registry.get_backend(config)now takes a second argument,credentials.Open points
Tests
155 tests pass on Python 3.11 and 3.13, with 99% coverage.
test_credentials.pyimportsintercede._backends.credentialsdirectly, because no real backend uses it yet.