Document toolboxDocument toolbox

Access Tokens

The OpenID Connect Provider from BankID provides by default Access Tokens with claims as shown in the below table. The origin column indicates non-standard claims. Such claims are either added by Keycloack or the result of customization made by the OIDC Provider from BankID.

The default access token structure builds on Keycloack and consists of the following three parts:

  • A General part telling that the supported token type corresponds to standard Bearer Token usage
  • An ID part that contains key claims from the corresponding ID Token
  • An Access part that contains details on resource access, including in particular the audience (aud) for the access token.

The supported default token type is self-contained since it contains enough information to determine the authorization context, in particular the following:

  • The issuer (iss)of the access token. See corresponding claim in ID Token.
  • The authorized party (azp) for the access token. See corresponding claim in ID Token.
  • The subject identifier (sub) of the access token, ie. a reference to the end-user (resource owner) that authorized the access token. See corresponding claim in ID Token.
  • Intended audience (aud)for the access token, ie. a reference to Value-Added Services (VAS) that the access token regulates access to. Note that this is not related to the corresponding claim in the ID Token. The audience for the ID Token (being the OIDC Client) is different from the audience for an Access Token (being the VAS in question). 
  • The specific set of resources that the access token grants access to, corresponding to the set of scopes included in the Authorize request that subsequently resulted in the issuance of the Access Token.

Note that access tokens for the Client Credential Grant have a different structure for the ID part since there is no ID Token involved in that case.

Note that the OIDC Provider from BankID currently supports multi-audience tokens. If an OIDC Client requests a set of scopes that affect several value-added services (VAS), each of the affected services will be listed in the aud claim of the access token.

This practise may be changed in a future release of the OIDC Provider from BankID by imposing a restriction to not allow requests for a set of scopes that affect more than one VAS in each request. Introducing such a single-audience restriction has the benefit of giving tighter control since a bearer token in wrong hands gives access to fewer resources. The downside of a single-audience restriction is that integration becomes more complex for OIDC clients since multiple requests must be made, one for each set of requested scopes, to get a series of access tokens, one for each affected VAS.

To be prepared for a possible future change from multi-audience access tokens to single-audience access tokens, OIDC Clients are recommened to not include a set of scopes in the same request that affects more that one VAS. The recommended integration practise is to use a series of subsequent requests for access tokens to separate VAS. Using this recommended integration practise will not break backwards compatibility if a single-audience restriction is introduced. For authentication flows involving the end-user subsequent requests can be made via the id_token_hint option for the Authorize endpoint to avoid repeated authentication of the end-user.

Note finally that the OIDC Provider form BankID supports signed Access Tokens in JWT format. The below table shows claims in the payload part of the JWT. Claims contained in the JWT header are not shown.See session handling for the life-time of an access token. To cater for access tokens that are either revoked before their expiry, or that have expired prematurely for other reasons, validation of access tokens via Introspect is supported. Another use of introspection is for eligible resource servers to retrive confidential claims that are not carried in the access token itself. One such examle is the bankid_altsub claim.

ClaimOriginScopeExampleDescriptionComment
General part
typKeycloackopenidBearerToken typeAlways Bearer for Access Tokens
allowed-originsKeycloackopenid[ ]Not in use by the OIDC Provider from BankID
ID part
acrStandardopenid4See ID Token
amrStandardopenidBIDSee ID Token 
auth_timeStandardopenid1510497762See ID Token 
azpStandardopenidoidc_testclientSee ID Token 
bankid_altsubCustomopenid9578-5999-4-1765512See ID Token 
expStandardopenid1510498063See session handling 
iatStandardopenid1510497763See session handling 
issStandardopenid<oidc-baseurl>See ID Token 
jtiStandardopenid7f22fd6a-3d46-4d5a-ae56-6de3c53e1873See ID Token 
nbfStandardopenid0See ID Token 
nonceStandardopenid<random value>See ID Token 
session_stateKeycloackopenidabf823c2-9810-4133-9369-7bff1223d6c1See ID Token 
subStandardopenid

e8c523ff-52a2-42e2-a7a5-f1d0fbb76204

See ID Token 
birthdateStandardopenid1966-12-18See ID Token 
family_nameStandardprofileNilsenSee ID Token 
given_nameStandardprofileFrode BeckmannSee ID Token 
nameStandardprofileNilsen, Frode BeckmannSee ID Token 
preferred_usernameStandardprofileNilsen, Frode BeckmannSee ID Token 
Access part
audStandardopenidtinfoAudienceList of VAS-names for which the access token in question is intended
realm_accessKeycloack

profile
address
phone
email nnin_altsub
nnin

{"roles:["profile","address","phone","email","nnin_altsub","nnin"]}

 

Resource access designator at the OIDC platform level.

 

resource_access
Keycloack

profile
address
phone
email
nnin

 

{"tinfo:{"roles ["address","phone_number", "email", "nnin"]}}
Resource access designator for the TINFO Service