-
Notifications
You must be signed in to change notification settings - Fork 151
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
Ability to set user credentials from strings(s) #885
Conversation
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.
LGTM
protected static string _loadUser(string text) | ||
{ | ||
StringReader reader = null; | ||
try |
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.
we could use using
here but I see it's lifted from the original file, so better to leave as is.
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.
Minor nits; also double checked we wouldn't introduce any issues with the new base class.
string text = secure.ToString(); | ||
|
||
// if it's a nk file, it only has the nkey | ||
if (text.StartsWith("SU")) | ||
{ | ||
return Nkeys.FromSeed(text); | ||
} | ||
|
||
// otherwise assume it's a creds file. | ||
reader = new StringReader(text); |
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.
Not sure why the original code had the ToString
string text = secure.ToString(); | |
// if it's a nk file, it only has the nkey | |
if (text.StartsWith("SU")) | |
{ | |
return Nkeys.FromSeed(text); | |
} | |
// otherwise assume it's a creds file. | |
reader = new StringReader(text); | |
// if it's a nk file, it only has the nkey | |
if (secure.StartsWith("SU")) | |
{ | |
return Nkeys.FromSeed(secure); | |
} | |
// otherwise assume it's a creds file. | |
reader = new StringReader(secure); |
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.
leftover from when I was trying secure. Will fix.
@@ -22,7 +23,7 @@ namespace NATS.Client | |||
/// not normally used directly, but is provided to extend or use for | |||
/// utility methods to read a private seed or user JWT. | |||
/// </summary> | |||
public class DefaultUserJWTHandler | |||
public class DefaultUserJWTHandler : BaseUserJWTHandler |
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.
Since we had a breaking change earlier I went and double checked this would not introduce any issues, and I don't believe it will:
❓ REQUIRES JUDGMENT: Introducing a new base class
A type can be introduced into a hierarchy between two existing types if it doesn't introduce any new abstract members or change the semantics or behavior of existing types. For example, in .NET Framework 2.0, the DbConnection class became a new base class for SqlConnection, which had previously derived directly from Component.
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 can change from base to a delegate
} | ||
return user.ToString(); |
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.
return user.ToString(); | |
return user; |
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, that was left over from trying secure.
} | ||
finally | ||
{ | ||
Nkeys.Wipe(line); | ||
Nkeys.Wipe(text); | ||
Nkeys.Wipe(seed); |
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.
FYI, these were removed because the wipe tries to wipe a string which is not possible. The wipe method was recently changed to a no-op.
No description provided.