-
Notifications
You must be signed in to change notification settings - Fork 9
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 apikey authenticator #46
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.
just some questions after a quick readthrough nan
src/IBM.Cloud.SDK.Core/Authentication/CloudPakForData/CloudPakForDataAuthenticator.cs
Outdated
Show resolved
Hide resolved
src/IBM.Cloud.SDK.Core/Authentication/CloudPakForData/CloudPakForDataAuthenticator.cs
Outdated
Show resolved
Hide resolved
src/IBM.Cloud.SDK.Core/Authentication/CloudPakForData/CloudPakForDataAuthenticator.cs
Outdated
Show resolved
Hide resolved
src/IBM.Cloud.SDK.Core/Authentication/CloudPakForData/CloudPakForDataTokenResponse.cs
Show resolved
Hide resolved
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.
It looks good, just a comment
} | ||
|
||
[TestMethod] | ||
public void TestConstructionApikeyRequried() |
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.
possible typo on the name of the method
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.
Ok. Will fix it. Thank you
Also need to check on CI here |
appveyor.yml
Outdated
@@ -17,6 +17,7 @@ environment: | |||
secure: gevsMhy8RTWMdf7MjOnIo5QaN6JpL9DPK6I+Go5ByZir5LDwyFsv9hO6nBjGTg8n #pragma: whitelist secret | |||
GITHUB_TOKEN: | |||
secure: +B2bs86RVtJtlbkB+cTf9bkqnNlFJi/PbBBPzR5jlUlLLZoOc+ZgqgQLwee4tCT+ #pragma: whitelist secret | |||
nodejs_version: 15.6.0 |
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 i made this change in another PR for core so it matches the .NET SDK node version
b422967
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.
Okay. I will remove this one. Thank you
/// <param name="headers">A set of user-supplied headers to be included in token server interactions</param> | ||
public CloudPakForDataAuthenticator(string url, string username, string password, string apikey, bool? disableSslVerification = null, Dictionary<string, string> headers = null) | ||
{ | ||
Init(url, username, password, apikey, disableSslVerification, headers); |
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.
@nan2iz did you get anywhere with the builder/fluent pattern 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.
I think if the builder pattern works, I dont think we need the 2nd overload.
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.
Okay. I will remove the overload. Thank you
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 threw some suggestions in here for consistency
/// <param name="headers">A set of user-supplied headers to be included in token server interactions</param> | ||
public CloudPakForDataAuthenticator(string url, string username, string password, string apikey, bool? disableSslVerification = null, Dictionary<string, string> headers = null) | ||
{ | ||
Init(url, username, password, apikey, disableSslVerification, headers); |
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 if the builder pattern works, I dont think we need the 2nd overload.
|
||
public CloudPakForDataAuthenticator SetUrl(string url) | ||
{ | ||
this.Url = url; |
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.
this.Url = url; | |
Url = url; |
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.
Thank you. Will fix it
|
||
public CloudPakForDataAuthenticator SetUsername(string username) | ||
{ | ||
this.Username = username; |
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.
this.Username = username; | |
Username = username; |
} | ||
|
||
private void Init(string url, string username, string password, bool? disableSslVerification = null, Dictionary<string, string> headers = null) | ||
public CloudPakForDataAuthenticator setPassword(string password) |
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.
public CloudPakForDataAuthenticator setPassword(string password) | |
public CloudPakForDataAuthenticator SetPassword(string password) |
private void Init(string url, string username, string password, bool? disableSslVerification = null, Dictionary<string, string> headers = null) | ||
public CloudPakForDataAuthenticator setPassword(string password) | ||
{ | ||
this.Password = this.Password; |
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.
this.Password = this.Password; | |
Password = password; |
return this; | ||
} | ||
|
||
public CloudPakForDataAuthenticator setApikey(string apikey) |
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.
public CloudPakForDataAuthenticator setApikey(string apikey) | |
public CloudPakForDataAuthenticator SetApikey(string apikey) |
|
||
public CloudPakForDataAuthenticator setApikey(string apikey) | ||
{ | ||
this.Apikey = this.Apikey; |
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.
this.Apikey = this.Apikey; | |
Apikey = apikey; |
|
||
public CloudPakForDataAuthenticator SetDisableSslVerification(bool disableSslVerification) | ||
{ | ||
this.DisableSslVerification = disableSslVerification; |
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.
this.DisableSslVerification = disableSslVerification; | |
DisableSslVerification = disableSslVerification; |
|
||
public CloudPakForDataAuthenticator SetHeaders(Dictionary<string, string> headers) | ||
{ | ||
this.Headers = headers; |
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.
this.Headers = headers; | |
Headers = headers; |
Note: I will need to wait until this PR #47 is merged to the master first. |
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.
Looks good!
/// <param name="username">The username to be used when retrieving the access token</param> | ||
/// <param name="password">The password to be used when retrieving the access token</param> | ||
/// <param name="disableSslVerification">A flag indicating whether SSL hostname verification should be disabled</param> | ||
/// <param name="headers">A set of user-supplied headers to be included in token server interactions</param> | ||
public CloudPakForDataAuthenticator(string url, string username, string password, bool? disableSslVerification = null, Dictionary<string, string> headers = null) | ||
{ | ||
Init(url, username, password, disableSslVerification, headers); | ||
Init(url, username, password, null, disableSslVerification, headers); |
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.
Do we still need apikey in init?
{ | ||
KeyValuePair<string, string> apikey = new KeyValuePair<string, string>(KeyApikey, Apikey); | ||
content.Add(apikey); | ||
} else |
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.
ah this else should be on a separate line
} else | |
} | |
else |
…r which use Dictinary config
… http post to use json type
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.
One comment then i think it looks good!
Init(); | ||
} | ||
|
||
private void Init(string url, string username, string password, string apikey, bool? disableSslVerification = null, Dictionary<string, string> headers = null) |
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.
Do we need default values for password and apikey here? I dont think its guaranteed the values will come back from the config
private void Init(string url, string username, string password, string apikey, bool? disableSslVerification = null, Dictionary<string, string> headers = null) | |
private void Init(string url, string username, string password = null, string apikey = null, bool? disableSslVerification = null, Dictionary<string, string> headers = null) | |
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.
👍 Looks good Thank you Nan!!
How to call the authenticator: