JWT (Json Web Token) Audience “aud” versus Client_Id - What's the difference?

后端 未结 4 1500
抹茶落季
抹茶落季 2020-12-07 08:05

I\'m working on implementing OAuth 2.0 JWT access_token in my authentication server. But, I\'m not clear on what the differences are between the JWT aud claim a

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 09:03

    Though this is old, I think question is valid even today

    My suspicion is that aud should refer to the resource server(s), and the client_id should refer to one of the client applications recognized by the authentication server

    Yes, aud should refer to token consuming party. And client_id refers to token obtaining party.

    In my current case, my resource server is also my web app client.

    In the OP's scenario, web app and resource server both belongs to same party. So this means client and audience to be same. But there can be situations where this is not the case.

    Think about a SPA which consume an OAuth protected resource. In this scenario SPA is the client. Protected resource is the audience of access token.

    This second scenario is interesting. There is a working draft in place named "Resource Indicators for OAuth 2.0" which explain where you can define the intended audience in your authorisation request. So the resulting token will restricted to the specified audience. Also, Azure OIDC use a similar approach where it allows resource registration and allow auth request to contain resource parameter to define access token intended audience. Such mechanisms allow OAuth adpotations to have a separation between client and token consuming (audience) party.

提交回复
热议问题