Feat: add enduser request API scopes for ID-porten/Maskinporten#2709
Merged
howieandersen merged 6 commits intomainfrom Mar 27, 2026
Merged
Conversation
- Add SCOPE_ENDUSER_REQUESTS_READ and SCOPE_ENDUSER_REQUESTS_WRITE constants - Create policies combining portal scope with request-specific scopes - Update RequestController endpoints to use new granular authorization policies
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces dedicated end-user (ID-porten/Maskinporten) OAuth scopes and authorization policies for the enduser request API, and updates the RequestController endpoints to use the new policies for read/write access.
Changes:
- Added new scope constants for enduser request read/write access.
- Added new authorization policies intended to require combined portal + request scopes.
- Updated RequestController endpoints to use the new request read/write policies.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 13 comments.
| File | Description |
|---|---|
src/apps/Altinn.AccessManagement/src/Altinn.AccessManagement/AccessManagementHost.cs |
Registers new scope-based authorization policies for enduser request read/write. |
src/apps/Altinn.AccessManagement/src/Altinn.AccessManagement.Core/Constants/AuthzConstants.cs |
Adds new scope and policy constants for enduser request API access. |
src/apps/Altinn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs |
Switches request endpoints from the prior policies to the new request read/write policies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
src/apps/Altinn.AccessManagement/src/Altinn.AccessManagement/AccessManagementHost.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
…endpoints Security fixes for request API authorization: 1. Restored ABAC-based party access checks by keeping both authorization policies on each endpoint: - POLICY_ACCESS_MANAGEMENT_ENDUSER_READ/WRITE enforces party-level ABAC - POLICY_ENDUSER_REQUESTS_READ/WRITE enforces scope requirements Without the ABAC policy, users with correct scopes could access/modify requests for any party, bypassing party authorization checks. 2. Fixed scope combination logic - removed portal scope from new request policies since ScopeAccessRequirement treats scope arrays as OR (any-of) not AND (all-of). The portal scope is already enforced at controller level, so endpoints now properly require: - Portal scope (controller-level) - Request scope (method-level) - Party access rights (ABAC policy) These changes ensure proper defense-in-depth authorization with scope-based access control AND attribute-based party authorization.
src/apps/Altinn.AccessManagement/src/Altinn.AccessManagement/AccessManagementHost.cs
Outdated
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Show resolved
Hide resolved
...nn.AccessManagement/src/Altinn.AccessManagement.Api.Enduser/Controllers/RequestController.cs
Outdated
Show resolved
Hide resolved
jonkjetiloye
approved these changes
Mar 27, 2026
Changed test token generation to use a single scope claim with space-separated values instead of multiple separate scope claims. ScopeAccessHandler only reads the first scope claim, so multiple claims caused authorization failures. Also replaced incorrect policy name constants with proper scope constants and added the new SCOPE_ENDUSER_REQUESTS_READ and SCOPE_ENDUSER_REQUESTS_WRITE scopes required by updated endpoints.
- CreatePortalClient: Portal scope only (currently unused) - CreateSystemClient: Request scopes only (used in all tests) - Fixed scope claim format: single space-separated string instead of multiple claims - Tests now reflect realistic production token patterns where portal and system scopes never coexist Portal client available for future regression testing but current tests focus on validating new system
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Added new scope-based authorization policies (POLICY_ENDUSER_REQUESTS_READ and POLICY_ENDUSER_REQUESTS_WRITE) that combine the portal scope with request-specific scopes for ID-porten/Maskinporten integration.
Updated all endpoints in RequestController to use these granular policies instead of the generic access management policies, enabling fine-grained authorization for end-user systems accessing the request API.
Description
Created new scope constants in AuthzConstants.cs:
Created new policy constants in AuthzConstants.cs:
Set up new scope policies in AccessManagementHost.cs:
Updated all RequestController endpoints with dual authorization:
Result: End-user systems with Maskinporten/ID-porten can now access the request API with proper granular
Related Issue(s)
Verification
Documentation