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

Add support for client credentials grant #30

Merged
merged 2 commits into from
Oct 16, 2018

Conversation

tomreay
Copy link
Contributor

@tomreay tomreay commented Oct 16, 2018

Implementing the client credentials grant.

This required setting the username field to be nullable as client_credentials grant implies no user. I've left username as non-null for the code token as you can never have a code token when using client credentials

@@ -293,7 +318,7 @@ class Oauth2TokenService(
override fun userInfo(accessToken: String): UserInfo {
val storedAccessToken = tokenStore.accessToken(accessToken) ?: throw InvalidGrantException()
val client = clientService.clientOf(storedAccessToken.clientId) ?: throw InvalidClientException()
val identity = identityService.identityOf(client, storedAccessToken.username)
val identity = storedAccessToken.username?.let { identityService.identityOf(client, it) }
?: throw InvalidIdentityException()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about throwing an InvalidIdentityException here? There is no identity, so it is invalid to try and get the identity, thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The exception can be removed. It should not show the username key and value in that case

Copy link
Contributor Author

@tomreay tomreay Oct 16, 2018

Choose a reason for hiding this comment

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

Sorry I'm not completely following - as in the method should return UserInfo?? In which case what response code should that map to?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I forgot it was called userInfo I think it should be renamed to tokenInfo and make identity nullable on TokenInfo (what is now called UserInfo).
In that case tokenInfo always provides all the information it haves. You can pick this up with this PR, otherwise I can pick this up outside of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think best to create a separate PR should be raised for this which I'm happy to do, I've created issue #32 to track work out the spec and track it

@adhesivee adhesivee merged commit 223ce15 into myndocs:develop Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants