nav-auth

Implement Azure AD JWT validation and TokenX exchange for Nav applications.

52|13|Updated Jan 10, 2025
One-click install
npx skills add https://github.com/navikt/copilot --skill nav-auth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nav-auth
Source: https://github.com/navikt/copilot/tree/main/.github/skills/nav-auth
Command: npx skills add https://github.com/navikt/copilot --skill nav-auth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents broken or insecure authentication and authorization in Nav applications by providing correct patterns for Azure AD, TokenX, ID-porten, Maskinporten, and JWT validation.

Core Features & Use Cases

  • Correct authentication wiring for Nav stacks: Implements Azure AD JWT validation (issuer, audience, signature) and service-to-service TokenX exchange flows.
  • Machine-to-machine and citizen access models: Covers Maskinporten scopes for external organizations and ID-porten sidecar configuration for citizens.
  • Practical debugging guidance: Includes commands and testing approaches to diagnose auth failures like audience mismatches, JWKS retrieval issues, and TokenX access-policy drift.

Quick Start

Configure your Nais app for Azure AD and validate incoming JWTs using the nav-auth skill patterns for issuer, JWKS, audience checks, and TokenX OBO exchange.

Frequently Asked Questions about nav-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate Azure AD JWT tokens in a NAIS application?

To validate Azure AD JWT tokens in a NAIS application, enforce strict checks for the token issuer, audience, signature, and expiration. The nav-auth patterns provide the correct configuration wiring to ensure incoming tokens are securely verified.

What is the best way to set up TokenX for service-to-service authentication?

TokenX enables secure service-to-service authentication through token exchange flows. You configure access policies and perform On-Behalf-Of (OBO) exchange to allow your NAIS app to securely call other services.

How do I configure ID-porten and Maskinporten for citizen and external access?

ID-porten secures citizen access via sidecar configuration, while Maskinporten handles external organization access using scoped tokens. Both require aligned NAIS application configuration to properly route and validate incoming requests.

Why does JWT validation fail with audience mismatch or JWKS retrieval issues?

JWT validation fails with audience mismatch or JWKS retrieval issues when the token's audience claim does not match your app or the JWKS endpoint is unreachable. Debug by verifying the issuer, audience, and access-policy alignment in your NAIS configuration.

How do I secure machine-to-machine callers using pre-authorized apps and azp claim matching?

To secure machine-to-machine callers, validate that the incoming token originates from a pre-authorized app by matching the azp claim. This guarded M2M validation ensures only explicitly allowed services can access your application endpoints.