Skip to content
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

Added OIDC Conformant UserInfo class and API Method #122

Merged
merged 2 commits into from
Jun 15, 2017

Conversation

cocojoe
Copy link
Member

@cocojoe cocojoe commented Jun 9, 2017

Public API Added (Open to name changes)

  • func userClaimInfo(token: String) -> Request<UserInfo, AuthenticationError>
  • public class UserInfo: NSObject, JSONObjectPayload

This adheres to the standard claims specification, although we may not support all claims. I feel we should support all properties for developer convenience. For example Facebook openid profile will return.

{"sub":"facebook|1010000000000","name":"Martin Walsh","given_name":"Martin","family_name":"Walsh"
,"nickname":"martin.walsh"
,"picture":"https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/myawesomeprofile.jpg"
,"gender":"male","locale":"en-US","updated_at":"2017-06-09T14:49:21.310Z"}

@cocojoe
Copy link
Member Author

cocojoe commented Jun 9, 2017

I need to add tests, just wanted to open up any further discussion.
Could possibly deprecate the old userInfo.

updatedAt = date(from: dateString)
}

let keys = Set(["sub", "name", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "profile", "picture", "website", "email", "email_verified", "gender", "birthdate", "zoneinfo", "locale",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if we do

let publicClaims = ["sub", "name", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "profile", "picture", "website", "email", "email_verified", "gender", "birthdate", "zoneinfo", "locale","phone_number", "phone_number_verified", "address", "updated_at"] // This can even be a static thing outside of the class since it won't change
let customClaims = json.filter { !publicClaims.contains($0.0) }

?

Copy link
Member Author

@cocojoe cocojoe Jun 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree publicClaims should be static.
The issue with filter here is it will return an array of tuples, so it's not quite as elegant as this one liner suggests.
In Swift 4 this works as a filtered dictionary will now return a dictionary. (As it should really)

@cocojoe cocojoe force-pushed the added-oidc-user-info branch 2 times, most recently from 0946448 to b326c74 Compare June 13, 2017 10:39
@cocojoe cocojoe added this to the v1-Next milestone Jun 13, 2017
- returns: a request that will yield user information
- important: This method should be used for OIDC Conformant clients.
*/
func userClaimInfo(token: String) -> Request<UserInfo, AuthenticationError>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to keep the userInfo name

@@ -103,7 +103,7 @@ public class Profile: NSObject, JSONObjectPayload {

}

private func date(from string: String) -> Date? {
func date(from string: String) -> Date? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try moving this to other file since its shared

hzalaz
hzalaz previously approved these changes Jun 15, 2017
@cocojoe cocojoe merged commit 4408c39 into master Jun 15, 2017
@cocojoe cocojoe deleted the added-oidc-user-info branch June 15, 2017 18:47
@cocojoe cocojoe modified the milestones: 1.7.0, v1-Next Jun 26, 2017
@cocojoe cocojoe mentioned this pull request Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants