Protect data endpoint
When receiving a request for data. You should perform the proper token validation and variable authorization to identify if the requester rightfully has access to claimed resource.
Validate Feide token
- Extract JSON Web Token (JWT) from the HTTP request's Authorization header using Bearer schema.
- Locate the public key needed for decoding the token by visiting
https://auth.dataporten.no/.well-known/openid-configuration and look for
property jwks_uri.
- Extract the public key found in the JSON Web Key Set (JWKS) URL from the previous step.
- Verify that the JWK's key identifier (kid) is the same as the received token's kid.
- Decode the received token using public key, expected audience (being your datasource's identifier) and RS256 algorithm.
- Validate token. See the
JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens
for full details about JWT access token validation.
- Ensure isshas to behttps://auth.dataporten.no
- Ensure audcontains your datasource's identifier.
- Ensure current time is in the interval between the iatandexptimestamps.
 
- Ensure 
Data authorization
- Having validated the Feide token you should extract subject identifier subin the token.
- Make a GET request to
https://kudaf-core.paas2.uninett.no/api/v1/permissions/{SUBJECT_ID}/{DATASOURCE_ID}
with parameters SUBJECT_IDfrom previous step andDATASOURCE_IDbeing your known datasource identifier from Kundeportalen.
- In the response, extract the token from the property authroizations.
- Validate KUDAF token
- Extract JSON Web Token (JWT) from the HTTP request's Authorization header using Bearer schema.
- Locate the public key needed for decoding the token by visiting
https://kudaf-core.paas2.uninett.no/api/v1/auth/.well-known/openid-configuration
and look for property jwks_uri.
- Extract the public key found in the JSON Web Key Set (JWKS) URL from the previous step.
- Verify that the JWK's key identifier (kid) is the same as the received token's kid.
- Decode the received token using public key, expected audience (being your datasource's identifier) and RS256 algorithm.
- Validate token. See the
JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens
for full details about JWT access token validation.
- Ensure isshas to bekudaf-core.paas2.uninett.no/api/v1/auth
- Ensure audcontains your datasource's identifier.
- Ensure current time is in the interval between the iatandexptimestamps.
 
- Ensure 
 
- Decode the token and map out the array of variables inside the datasource property.
- Authorize access to data based on permitted variables from previous step.