-
Notifications
You must be signed in to change notification settings - Fork 15
[dotnet] Experimental platform-specific token provider with dependency injection support #492
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
Conversation
7cb5ab9 to
ae3359e
Compare
|
|
||
| if (!response.Profile.Protection?.Enabled ?? true) await TokenProvider.SaveAsync(authToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that this saves the token as a default name and caches it in the concrete implementations - do we want to standardize on a naming scheme? Something like <ecosystemID>.<email>? though there might not always be an email.
Everything gets saved as the default name now, correct? How will users switch to use another token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token provider is completely ignored if they pass auth token through the options, this is how they would use multi-user setups.
As you pointed out, the implementation does leave room for named tokens, once we have a clear path on how to do this. I'm curious to dig further on how many use cases there are where multi user tokens would be needed, outside of our unit tests and dev work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think named tokens will be very useful in the future when developers are integrating multiple trinsic ecosystems together. Having an easy way to work with named tokens now will just be icing on the cake in the future. Also, don't forget our unit tests and dev work (as you mentioned).
I am also envisioning a future in which we are developing the sample applications in conjunction with customers @michaeldboyd can back me up on this, and being able to switch between our ecosystem and our customer's ecosystem would be really handy.
| using System; | ||
| using System.IO; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Trinsic; | ||
|
|
||
| internal class FileTokenProvider : ITokenProvider | ||
| { | ||
| private const string Vendor = "Trinsic"; | ||
|
|
||
| public static FileTokenProvider StaticInstance => new(); | ||
|
|
||
| private string? _cachedToken; | ||
|
|
||
| public async Task<string?> GetAsync(string name = TokenDefaults.Name, CancellationToken cancellationToken = default) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which of these providers do we want to replicate in other languages? @sethjback @tmarkovski do we want to create a discussion issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, definitely start a separate discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extensions are added side by side, and the previous API is unchaged