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

Move caching stuff off the IAccessTokenProvider API into the factory #373

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

j3parker
Copy link
Member

No description provided.


return new CachedAccessTokenProvider( noCacheTokenProvider, authEndpoint, Timeout.InfiniteTimeSpan );
return new CachedAccessTokenProvider( new NullCache(), noCacheTokenProvider, authEndpoint, Timeout.InfiniteTimeSpan );
Copy link
Member Author

Choose a reason for hiding this comment

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

tests

) {
if( inner != null && cache == null ) {
throw new InvalidOperationException( "If you provide an inner you need to also provide its cache" );
Copy link
Member Author

Choose a reason for hiding this comment

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

The idea here is that this factory is either for wrapping your IAccessTokenProvider in our caching layer (for which you provide an ICache for us to use) or for using our jwt-bearer-grant based impl with or without caching.

The reason I'm doing this is I want to implement an IamGrant IAccessTokenProvider impl. I want to do that inside the LMS because I'd really like to use the LMS Lambda framework. It would make sense to implement it in this library, and I mean you could at least define the input/output here, but meh.

/// check for token expiration or grace period because the
/// <see cref="IAccessTokenProvider"/> will handle it internally.</param>
/// <returns>An access token containing an expiry and the provided claims and scopes.</returns>
[GenerateSync]
Task<IAccessToken> ProvisionAccessTokenAsync(
IEnumerable<Claim> claims,
IEnumerable<Scope> scopes,
ICache cache = null
IEnumerable<Scope> scopes
Copy link
Member Author

Choose a reason for hiding this comment

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

Consolidating on one interface, equivalent to the old non-caching one, and taking the cache inside the factory+constructor.

The LMS cache is instantiated each call but it can be safely cached.

@j3parker j3parker marked this pull request as ready for review November 29, 2024 18:44
@j3parker j3parker requested a review from omsmith as a code owner November 29, 2024 18:44
@j3parker
Copy link
Member Author

I jumped the gun on bumping the version after the previous PR... on auto-pilot.

@j3parker j3parker merged commit 5adb1c8 into master Nov 29, 2024
2 checks passed
@j3parker j3parker deleted the iaccesstokenprovider-api-tweaks branch November 29, 2024 18:54
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.

2 participants