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
iss
has to behttps://auth.dataporten.no
- Ensure
aud
contains your datasource's identifier. - Ensure current time is in the interval between the
iat
andexp
timestamps.
- Ensure
Data authorization
- Having validated the Feide token you should extract subject identifier
sub
in the token. - Make a GET request to
https://kudaf-core.paas2.uninett.no/api/v1/permissions/{SUBJECT_ID}/{DATASOURCE_ID}
with parameters
SUBJECT_ID
from previous step andDATASOURCE_ID
being 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
iss
has to bekudaf-core.paas2.uninett.no/api/v1/auth
- Ensure
aud
contains your datasource's identifier. - Ensure current time is in the interval between the
iat
andexp
timestamps.
- 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.