-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add callback to NatsAuthOpts that allows refreshing a Token #712
base: main
Are you sure you want to change the base?
Conversation
7bf2f6f
to
c85fb33
Compare
@mtmk are you the right person to review this? Or is there someone else that might be good to reach out to? Thanks! |
@@ -31,6 +32,8 @@ public UserCredentials(NatsAuthOpts authOpts) | |||
|
|||
public string? Token { get; } | |||
|
|||
public Func<Task<string>>? TokenHandler { get; } |
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.
to be consistent with other callbacks should we make this ValueTask
. Can't remember if we also pass cancellation token. Also what about JWT? would that benefit from a callback like 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.
I modified my initial commit to be a ValueTask
rather than a Task
: 21c6654
From what I can tell in other places, it doesn't appear that a cancellation token is passed.
In 58864dc, I added callbacks for JWT, NKey, and seed. Based on my understanding, if the JWT is being refreshed, the seed also needs to be refreshed. And the same goes with NKeys. I added unit tests to show that the callbacks will take precedence over any raw values that are set on initialization of NatsAuthOpts.
@garrett-sutton could you sign your commits please? |
34d3941
to
0bdb854
Compare
0bdb854
to
fb423fb
Compare
Done. As a note, this should probably be called out in |
Adds the following to
NatsAuthOpts
Func<ValueTask<string>>? TokenHandler
Func<ValueTask<string>>? NKeyHandler
Func<ValueTask<string>>? JwtHandler
Func<ValueTask<string>>? SeedHandler
The purpose of this PR is to allow for use cases to refresh a Token, JWT, or NKey associated with their NatsConnection during a reconnect scenario.
resolves #356