Skip to content

Maskinporten Client

Status: Opt-In Open Beta

This feature is only available in the Google Cloud Platform (GCP) clusters.


Maskinporten allows API providers (external agencies) to define access to their APIs, modeled as scopes and based on the organization number.

Maskinporten is a service that offers a simple API security model based on the OAuth2 protocol, and the use of JWT bearer grants. A Concept inspired by Google's System Accounts.

The NAIS platform provides support for simple declarative provisioning of an Maskinporten client that your application may use to integrate with Maskinporten.

An Maskinporten 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 implement JWT grants.


Getting Started

apiVersion: ""
kind: "Application"
   name: nais-testapp
   namespace: aura
       team: aura
  image: navikt/nais-testapp:66.0.0
    enabled: true
      - scope: "nav:some/scope"


See the NAIS manifest.

Access Policies

The following outbound external hosts are automatically added when enabling this feature:

  • in development
  • in production

You do not need to specify these explicitly.


Maskinporten allows API providers to define access to their APIs, modeled as scopes and based on the consumer's organization number.

When a client requests a token from Maskinporten: - Maskinporten validates the validity of the JWT and signature (Runtime JWK Secret used to sign the JWT).
- When client has access to the requested resources: scope, an access_token will be returned to the client and can be used for further actions.


Make sure that the relevant service providers have pre-registered NAV as a valid consumer of any scopes that you define. Provisioning of client will fail otherwise. NAVĀ“s pre-registered scopes can be found with proper access rights in Digdir selvbetjening.


Runtime Variables and Credentials

The following environment variables and files (under the directory /var/run/secrets/ are available at runtime:

Name Values
MASKINPORTEN_CLIENT_ID e89006c5-7193-4ca3-8e26-d0990d9d981f
MASKINPORTEN_SCOPES nav:first/scope nav:another/scope
"use": "sig",
"kty": "RSA",
"kid": "jXDxKRE6a4jogcc4HgkDq3uVgQ0",
"alg": "RS256",
"n": "xQ3chFsz...",
"e": "AQAB",
"d": "C0BVXQFQ...",
"p": "9TGEF_Vk...",
"q": "zb0yTkgqO...",
"dp": "7YcKcCtJ...",
"dq": "sXxLHp9A...",
"qi": "QCW5VQjO..."


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 description of the client registered in the IaC repository follows the naming scheme:

Step 3 - Deploy your NAIS application with Maskinporten provisioning enabled

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.


See ID-porten internals.