Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(rust): extract a credential refresher from the credential retriever #7614

Closed
wants to merge 1 commit into from

Conversation

etorreborre
Copy link
Member

@etorreborre etorreborre commented Feb 19, 2024

This PR refactors part of the support for refreshing credentials in the background.

Configuration

The configuration for the CredentialRetriever is now just limited to pure data. CredentialRetrieverOptions are:

pub enum CredentialRetrieverOptions {
    /// No credential retrieval is required
    None,
    /// Credentials must be retrieved from cache, for a given issuer
    CacheOnly(Identifier),
    /// Credentials are retrieved via a remote authority
    Remote {
        /// Routing information to the issuer
        retriever_info: RemoteCredentialRetrieverInfo,
        /// Timing options for retrieving credentials
        retriever_timing_options: RemoteCredentialRetrieverTimingOptions,
        /// Timing options for refreshing credentials
        refresher_timing_options: RemoteCredentialRefresherTimingOptions,
    },
    /// Credentials have been provided in-memory
    InMemory(CredentialAndPurposeKey),
}

This provides a better separation between "configuring" and "initializing / running".

Refresher creation

The instantiation of a CredentialsRefresher, for a given issuer + identity is done at the last moment, when creating a secure channel:

  • This removes the need for a CredentialsRetrieverCreator.
  • This removes the need for no-op functions since refresh is only relevant for a remote credential retriever.

Retrievers / Refreshers

The functionality for retrieving credentials has been divided into:

  • IssuerClient: can create a secure channel to an issuer on another node and ask for a credential

  • CredentialRequest: can be executed to issue a credential for a specific pair issuer / subject

    • It is used to make sure that we don't try to concurrently retrieve the same credential.
    • The request has a run() method calling the issuer client and then caching the issued credential.
  • CredentialsCache: stores credentials locally and makes sure that they are not expired when they are retrieved from storage.

  • CredentialIssuer: this struct represents an issuer that we wish to access to get credentials

    • It creates credential requests when we need to get credentials for a given subject
  • CredentialRefresher: periodically asks the credential issuer to get new credentials so that we never have expired
    credentials for a given identity. It can also notify subscribers that new credentials are available.
    This feature is used to send a CredentialRefresh message on secure channels used by the subject.

  • RemoteCredentialRetriever: implementation of a CredentialRetriever accessing a remote issuer.
    It can spawn refreshers, one per subject.

   +--------------+
   | IssuerClient |
   +--------------+
            ^
            |
   +-------------------+            +------------------+
   | CredentialRequest |----------->| CredentialsCache |
   +-------------------+            +------------------+
            ^                                ^
            |                                |
   +------------------+             +---------------------+
   | CredentialIssuer |<------------| CredentialRefresher |
   +------------------+             +---------------------+
             ^                               ^
             |                               |
             |        +----------------------+
             |        |
   +---------------------------+
   | RemoteCredentialRetriever |
   +---------------------------+

@etorreborre etorreborre self-assigned this Feb 19, 2024
@etorreborre etorreborre force-pushed the etorreborre/refactor/retrieve-refresh branch 3 times, most recently from d049c80 to 9a8d2f1 Compare February 20, 2024 09:40
@etorreborre etorreborre marked this pull request as ready for review February 20, 2024 10:39
@etorreborre etorreborre requested a review from a team as a code owner February 20, 2024 10:39
@etorreborre etorreborre force-pushed the etorreborre/refactor/retrieve-refresh branch 18 times, most recently from 3322a6c to 05b6e46 Compare March 11, 2024 12:26
@etorreborre etorreborre marked this pull request as draft March 11, 2024 12:39
@etorreborre etorreborre force-pushed the etorreborre/refactor/retrieve-refresh branch from 05b6e46 to ac00dc7 Compare March 11, 2024 14:52
@etorreborre etorreborre force-pushed the etorreborre/refactor/retrieve-refresh branch from ac00dc7 to becaa9e Compare March 11, 2024 15:17
@etorreborre etorreborre marked this pull request as ready for review March 11, 2024 15:33
@etorreborre etorreborre enabled auto-merge March 11, 2024 17:01
auto-merge was automatically disabled January 24, 2025 10:17

Pull request was closed

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.

1 participant