-
Notifications
You must be signed in to change notification settings - Fork 140
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
SNOW-715504: MFA token cache support #988
base: master
Are you sure you want to change the base?
Conversation
6eba99f
to
69d80c7
Compare
a8dff4b
to
67089fc
Compare
Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs
Outdated
Show resolved
Hide resolved
6af9d1a
to
e36f8ed
Compare
e795b5f
to
9316bbc
Compare
9316bbc
to
43adef9
Compare
Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs
Outdated
Show resolved
Hide resolved
Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs
Outdated
Show resolved
Hide resolved
Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs
Outdated
Show resolved
Hide resolved
3894dae
to
b1ec82b
Compare
Snowflake.Data.Tests/UnitTests/CredentialManager/SFCredentialManagerTest.cs
Outdated
Show resolved
Hide resolved
Snowflake.Data.Tests/UnitTests/CredentialManager/SFCredentialManagerTest.cs
Outdated
Show resolved
Hide resolved
Snowflake.Data.Tests/UnitTests/CredentialManager/SFCredentialManagerTest.cs
Outdated
Show resolved
Hide resolved
Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs
Show resolved
Hide resolved
0be7aa9
to
ce1b619
Compare
Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs
Show resolved
Hide resolved
5d32b9c
to
be6f19d
Compare
a9cec2f
to
10f124b
Compare
…each credential manager implementation.
Added write file validator for file permissions. Additional PR suggestions
7675dcf
to
2f1c811
Compare
2f1c811
to
c709726
Compare
{ | ||
if (s_credentialManager == null) | ||
{ | ||
s_credentialManager = s_defaultCredentialManager; |
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.
Is it necessary to check if s_credentialManager == null
inside lock
does lock mean possibly waiting for another thread setting this value? Also why are we checking it on Get
instead of setting defaultCredentialManager as a default value of s_credentialManager
?
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 reason to check if manager is null inside the lock is that even though it was null before the lock could stop the thread for a while so after waking up the situation can be different (another thread could initialise the manager).
Your second question is why not to initialise the s_credentialManager with the default value in the constructor? Maybe we could do so. The idea could be that we wanted to have lazy initialisation...
I changed it.
@@ -101,6 +101,24 @@ protected void Login() | |||
/// <param name="data">The login request data to update.</param> | |||
protected abstract void SetSpecializedAuthenticatorData(ref LoginRequestData data); | |||
|
|||
protected void SetSecondaryAuthenticationData(ref LoginRequestData data) |
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.
nit: could we add a doc string to this method? Probably it's because I'm reading it in the morning but I understood secondary authentication data as some less important data instead of data related to the second authentication factor
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.
"less important data" - then it would be AuthtneticationSecondaryData not SecondaryAuthenticationData. I don't like commenting what a method is doing. I would prefer give it a better name if you could propose anything better.
|
||
internal KeyTokenDict ReadJsonFile() | ||
{ | ||
var contentFile = _fileOperations.ReadAllText(_fileStorage.JsonCacheFilePath, ValidateFilePermissions); |
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.
Should we make sure that the file exists first? I see that we're checking it before each call to this method but if we're returning new KeyTokenDict
for the deserialization (corrupted file) then it'd make sense to return the same for non existing file?
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 added handling the case if the file was deleted just after we checked it.
KeyTokenDict keyTokenPairs = _fileOperations.Exists(_fileStorage.JsonCacheFilePath) ? ReadJsonFile() : new KeyTokenDict(); | ||
keyTokenPairs[key] = token; | ||
var credentials = new CredentialsFileContent { Tokens = keyTokenPairs }; | ||
string jsonString = JsonConvert.SerializeObject(credentials); |
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.
really really nit: JsonConvert.SerializeObject(credentials)
could be passed directly to WriteToJsonFile
to match line#149
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 changed it
Description
Added support for MFA token cache.
Checklist
dotnet test
)