Skip to content

Conversation

@tmarkovski
Copy link
Contributor

@tmarkovski tmarkovski commented Mar 18, 2022

  • Adds support for automatically saving and retrieving tokens for different platforms
  • Adds extensions for dependency injection using common net core services
  • Some cleanup in the dotnet code
  • Minor changes to point tests to staging by default

The extensions are added side by side, and the previous API is unchaged

@tmarkovski tmarkovski force-pushed the TM/dotnet-token-provider branch from 7cb5ab9 to ae3359e Compare March 18, 2022 13:32
@tmarkovski tmarkovski enabled auto-merge (squash) March 18, 2022 14:54
Comment on lines +51 to +52

if (!response.Profile.Protection?.Enabled ?? true) await TokenProvider.SaveAsync(authToken);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Comment on lines +1 to +16
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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tmarkovski tmarkovski merged commit 95ac9c2 into main Mar 18, 2022
@tmarkovski tmarkovski deleted the TM/dotnet-token-provider branch March 18, 2022 16:04
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.

4 participants