The NAIS platform provides support for simple declarative provisioning of a client that your application may use to integrate with Maskinporten, and in turn consume services and APIs served by external agencies.
The client allows your application to leverage Maskinporten for authentication and authorization when performing service-to-service requests to external agencies. To achieve this, your application must:
When a client requests a token from Maskinporten:
- Maskinporten validates the validity of the JWT and its signature (Runtime JWK Secret used to sign the JWT).
- If the client has access to the requested list of
access_tokenwill be returned to the client. The token can be used for authentication to the intended external service.
Make sure that the relevant service providers have pre-registered NAV's organization (number:
889640782) as a valid consumer of any scopes that you define. Provisioning of client will fail otherwise.
pre-registered scopes can be found with proper access rights in Digdir selvbetjening.
Maskinporten is a third-party service outside of our clusters, which is not reachable by default like most third-party services.
Google Cloud Platform (GCP)¶
The following outbound external hosts are automatically added when enabling this feature:
You do not need to specify these explicitly.
You must enable and use
webproxy for external communication.
See the NAIS manifest.
Runtime Variables and Credentials¶
The following environment variables and files (under the directory
/var/run/secrets/nais.io/maskinporten) are available at runtime:
Client ID that uniquely identifies the application in Maskinporten.
The scopes registered for the client at Maskinporten as a whitepace-separated string. See JWT grants for more information.
The well-known URL for the OAuth 2.0 authorization server (in this case, Maskinporten) metadata document.
issuer from the metadata discovery document.
jwks_uri from the metadata discovery document.
token_endpoint from the metadata discovery document.
Consuming an API¶
Refer to the documentation at DigDir.
You may skip any step involving client registration as this is automatically handled when enabling this feature.
This section only applies if you have an existing client registered at the IaC repository
Migration guide to keep existing Maskinporten client (NAIS application only)¶
The following describes the steps needed to migrate a client registered in IaC repository.
Step 1 - Update your client description in the IaC repository¶
- Ensure the
descriptionof the client registered in the
IaCrepository follows the naming scheme:
Step 3 - Deploy your NAIS application with Maskinporten provisioning enabled¶
- See configuration.
Step 4 - Delete your application from the IaC repository¶
- Verify that everything works after the migration
- Delete the application from the IaC repository in order to maintain a single source of truth.