-
Notifications
You must be signed in to change notification settings - Fork 232
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 support for extended profile using SIWA token exchange #322
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.
This is a particular use case / scenario. I don't think the mapping of user object values is responsibility of the Authentication#tokenExchange
method. cc @cocojoe
Agreed it's not the responsibility of the core tokenExchange method. However, is fine to happen inside the apple specific wrapper of this method. |
Auth0/Authentication.swift
Outdated
@@ -911,21 +911,38 @@ public extension Authentication { | |||
``` | |||
Auth0 | |||
.authentication(clientId: clientId, domain: "samples.auth0.com") | |||
.tokenExchange(withAppleAuthorizationCode: authCode, scope: "openid profile offline_access", audience: "https://myapi.com/api) | |||
.tokenExchange(withAppleAuthorizationCode: authCode, fullName: credentials.fullName, scope: "openid profile offline_access", audience: "https://myapi.com/api) |
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.
please change parm order to match 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.
Done.
Auth0Tests/AuthenticationSpec.swift
Outdated
@@ -215,33 +215,40 @@ class AuthenticationSpec: QuickSpec { | |||
} | |||
|
|||
} | |||
|
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.
What reformatting did you apply to this 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.
Not sure: I based this off of a spike that appears to have already included the whitespace changes. I've reverted them, but let me know if anything still looks off.
Cartfile.resolved
Outdated
@@ -1,4 +1,4 @@ | |||
github "AliSoftware/OHHTTPStubs" "8.0.0" | |||
github "Quick/Nimble" "v8.0.2" | |||
github "Quick/Quick" "v2.1.0" | |||
github "Quick/Nimble" "v8.0.4" |
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 would prefer deps are updated in a separate PR. However, I'm okay with it.
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 was unintentional on my part, so I removed this change.
@@ -283,7 +290,22 @@ class AuthenticationSpec: QuickSpec { | |||
} | |||
} | |||
} | |||
|
|||
|
|||
it("should exchange apple auth code for credentials with fullName") { |
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.
are there any cases it will fail e.g. if first name is missing or last name is missing?
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.
No, there are not. The values can be missing or null
and it won't cause any issues. Now, I've filtered them out if there is no value.
Auth0/Authentication.swift
Outdated
"subject_token": authCode, | ||
"subject_token_type": "http://auth0.com/oauth/token-type/apple-authz-code", | ||
"scope": scope ?? "openid profile offline_access" ] | ||
if fullName != nil { |
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.
You can tweak this a little
if let fullName = fullName,
let jsonData = try? String(
This also lets you remove the optionals in the JSON Object.
Auth0/Authentication.swift
Outdated
if fullName != nil { | ||
if let jsonData = try? String( | ||
data: JSONSerialization.data( | ||
withJSONObject: [ |
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 to check the endpoint is fine to accept null values?
{\"lastName\":\"Walsh\",\"firstName\":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.
Yes, null
values are okay.
@Widcket can you take a look as well, please |
} | ||
it("should exchange apple auth code for credentials with fullName") { | ||
var fullName = PersonNameComponents() | ||
fullName.givenName = "John" |
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.
Can you please add test cases for when the name and/or surname are nil?
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.
Added.
This is fraud please contact me at 480-506-8408
…On November 12, 2019 at 9:43 AM, Drew ***@***.***>wrote:
@asmcleancommented on this pull request.
InAuth0Tests/AuthenticationSpec.swift(#322 (comment)):
>@@ -284,8 +292,24 @@ class AuthenticationSpec: QuickSpec { } } - } + it("should exchange apple auth code for credentials with fullName") { + var fullName = PersonNameComponents() + fullName.givenName = "John"
Added.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly,view it on GitHub(#322?email_source=notifications&email_token=ANMQPERWM5BLKSRNOBXOV7LQTLMLDA5CNFSM4JLX67Q2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCLIOIIY#discussion_r345318171), orunsubscribe(https://github.com/notifications/unsubscribe-auth/ANMQPER2DRTGB4WBQY5BDSTQTLMLDANCNFSM4JLX67QQ).
|
@asmclean Please can you rebase against master and I'll approve this. Thanks |
Never mind I thought update was blocked, I should be good to approve in 5 mins 😄 |
* Add support for extended profile using SIWA token exchange * Fix indenting/whitespace * Revert accidental Cartfile.resolved changes * Reorder SIWA parameters, and stop sending missing values * Expand test cases for SIWA
Changes
Add support for getting name properties from the
fullName
property in the credential when using Sign In with Apple and token exchange. This will extract and send only values for the first and last name, similar to what's provided in theuser
parameter by the SIWA for websites.References
Testing
Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.
Checklist