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

oauth2: Allow multiple audience claims on ID token #790

Closed
lsthornt opened this issue Feb 23, 2018 · 9 comments
Closed

oauth2: Allow multiple audience claims on ID token #790

lsthornt opened this issue Feb 23, 2018 · 9 comments
Assignees
Labels
Milestone

Comments

@lsthornt
Copy link

In our setup, we have a backend and frontend service that are both issued different client ids.

Once logged into the frontend service, we have an ID token with {aud: "frontend"}, but it cannot be used to make requests to the backend service, because the aud claim must match the client_id of the backend service.

OpenID Connect claims docs:

aud
REQUIRED. Audience(s) that this ID Token is intended for. It MUST contain the OAuth 2.0 client_id of the Relying Party as an audience value. It MAY also contain identifiers for other audiences. In the general case, the aud value is an array of case sensitive strings. In the common special case when there is one audience, the aud value MAY be a single case sensitive string.

Looks like #314 took care of making the claim an array, so presumably this would involve an addition to AcceptOAuth2ConsentRequest, potentially just a special case for when aud is included in Access/IdTokenExtra?

@aeneasr
Copy link
Member

aeneasr commented May 20, 2018

Sorry for my silence on this, but we tracked this issue internally and will address it with the 1.0.0 release!

@aeneasr aeneasr added this to the 1.0.0-alpha.1 milestone May 20, 2018
@aeneasr aeneasr self-assigned this May 20, 2018
@aeneasr aeneasr changed the title Allow multiple audience claims on ID token oauth2: Allow multiple audience claims on ID token May 20, 2018
@aeneasr
Copy link
Member

aeneasr commented May 25, 2018

This is an upstream issue in fosite (patch pending). When upgrading, we'll also have to change how IDTokenClaims is initialized in oauth2/handler.go.

@aeneasr aeneasr modified the milestones: 1.0.0-alpha.1, 1.0.0 May 25, 2018
aeneasr pushed a commit that referenced this issue May 29, 2018
This patch resolves issues related to the ID and Access Token audience
claim:

* oauth2: Allow multiple audience claims on ID token - closes #790
* oauth2: Reintroduce audience claim - closes #687
@OvermindDL1
Copy link

For note, I'm trying to run the master HEAD version of hydra right now and multiple OpenID Connect libraries are reporting something akin to:

oauth2: error validating JWT token: audience in token does not match client key

Such as, for an open source example, the one at: https://github.com/go-gitea/gitea/blob/master/vendor/github.com/markbates/goth/providers/openidConnect/openidConnect.go#L202

@OvermindDL1
Copy link

And more testing, it looks like hydra is returning "aud":["my_client_id"] instead of "aud":"my_client_id", which is what these libraries expect. Any chance of hydra putting out a string instead of an array when it is only a single value?

@aeneasr
Copy link
Member

aeneasr commented Sep 6, 2018

This is tracked as #883

@aeneasr
Copy link
Member

aeneasr commented Sep 6, 2018

Regarding string/array - array MUST be supported according to spec. String MAY be supported, see JWT spec:

In the general case, the "aud" value is an array of case-
sensitive strings, each containing a StringOrURI value. In the
special case when the JWT has one audience, the "aud" value MAY be a
single case-sensitive string containing a StringOrURI value. The
interpretation of audience values is generally application specific.
Use of this claim is OPTIONAL.

@OvermindDL1
Copy link

Regarding string/array - array MUST be supported according to spec. String MAY be supported, see JWT spec:

Yep, I've already submitted a PR to them. Just curious if there is a way to just send a single string regardless when there is only a single string in the array, at the very least it lowers processing and network time every so tiny slightly. :-)

@aeneasr
Copy link
Member

aeneasr commented Sep 6, 2018 via email

@OvermindDL1
Copy link

I think that was a similar issue the library itself had, they ended up writing their own (obviously incomplete) JWT handler, my fix for this issue for them is at: markbates/goth#240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants