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

Joe/remote api token retreival #168

Merged
merged 8 commits into from
Jun 1, 2023
Merged

Conversation

josephdecock
Copy link
Member

This PR adds a new abstraction for describing how a BFF endpoint should retrieve access tokens. The intention is to allow for more flexibility when mapping remote bff api endpoints, without needing to drop into the complexity of YARP.

Usage of the abstraction looks like this:

endpoints.MapRemoteBffApiEndpoint("/api/impersonation", "https://localhost:5010")
                .RequireAccessToken(TokenType.UserOrClient)
                .WithAccessTokenRetriever<ImpersonationAccessTokenRetriever>();

On a per endpoint basis, you specify the mechanism for access token retrieval. If you don't specify, you get a default retriever with the same behavior as you would get today.

Access token retrievers look like this:

public interface IAccessTokenRetriever
{
    Task<AccessTokenResult> GetAccessToken(AccessTokenRetrievalContext context);
}

You're passed a context object containing the http context and metadata, etc, and return a result containing a token.

The main use case that I have in mind for this came from a support issue where the user wanted to perform token exchange before calling apis.

@brockallen brockallen added the enhancement New feature or request label Jun 1, 2023
@brockallen brockallen added this to the 2.1.0 milestone Jun 1, 2023
@brockallen brockallen merged commit 83e9045 into main Jun 1, 2023
@brockallen brockallen deleted the joe/remote-api-token-retreival branch June 1, 2023 17:38
@josephdecock
Copy link
Member Author

Related: #152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants