Skip to content

fix(party): allow delegated access without instantiation rights#4326

Merged
olemartinorg merged 3 commits into
mainfrom
codex/fix-existing-instance-party-check
Jul 23, 2026
Merged

fix(party): allow delegated access without instantiation rights#4326
olemartinorg merged 3 commits into
mainfrom
codex/fix-existing-instance-party-check

Conversation

@olemartinorg

@olemartinorg olemartinorg commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

Users with delegated access to an existing app instance could be shown a 403 error when they were not also allowed to start new instances of that app.

The party provider now applies the requirement for an instantiation-capable party only when entering the app without an existing instance. Backend authorization remains responsible for deciding whether the user can open a specific instance.

A Cypress regression test creates and saves an organization-owned instance, removes the user's allowed-to-instantiate parties from the frontend response when reopening it, and verifies that the user can still open the existing instance through real backend authorization.

Related Issue(s)

Verification/QA

Automated verification performed:

  • npx cypress run --env environment=podman -s test/e2e/integration/signering-brukerstyrt/existing-instance-access.ts --config retries=0 --reporter spec — 1 passing

  • npx cypress run --env environment=tt02 -s test/e2e/integration/signering-brukerstyrt/existing-instance-access.ts --config retries=0 --reporter spec — 1 passing

  • Negative control with the bug fix temporarily reverted — the same test failed in podman and TT02 because the existing instance form did not render

  • yarn eslint src/features/party/PartiesProvider.tsx test/e2e/integration/signering-brukerstyrt/existing-instance-access.ts — passed

  • yarn tsc — passed

  • Manual functionality testing

    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests

    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)

    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs

    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio

    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board

    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels

    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

PartyProvider rejected every authenticated user whose allowed-to-instantiate
party list was empty, even when the URL already identified an existing
instance. This prevented delegated users from opening instances the backend
authorized them to access.

Limit the empty-party error to entry without an instance ID. Cover the
distinction with a signing flow where the signer has real delegated access
while the allowed-to-instantiate response is deliberately empty.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

SelectedPartyProvider now permits existing-instance flows when no valid parties are available but an instance ID exists. A Cypress test covers delegated signer access by reopening an instance with an empty allowed-parties response.

Changes

Delegated signer instance access

Layer / File(s) Summary
Instance-aware party validation
src/features/party/PartiesProvider.tsx
SelectedPartyProvider reads the lax instance ID and renders NoValidPartiesError only when both the instance ID and valid parties are absent.
Delegated signer regression coverage
test/e2e/integration/signering-brukerstyrt/delegated-signer-instance-access.ts
The Cypress test creates an instance, reopens it as a delegated signer with no allowed parties, and verifies a successful instance response and signing view.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and Cypress test address #19576 by allowing existing instances when no instantiable party remains.
Out of Scope Changes check ✅ Passed The changes are limited to the party provider and a regression test, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly matches the main fix: letting delegated users open existing instances without instantiation rights.
Description check ✅ Passed The description includes the required summary, linked issue, and QA details, with only minor template placeholders left incomplete.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-existing-instance-party-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@test/e2e/integration/signering-brukerstyrt/delegated-signer-instance-access.ts`:
- Around line 20-27: Update the cy.intercept call for the allowed-parties GET
request to provide the response body type as IParty[] through its generic
parameters, then remove the res.body cast and use the inferred typed value in
the filtering logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 03fe8482-fadd-4826-871c-76e6cb7e0c9b

📥 Commits

Reviewing files that changed from the base of the PR and between 6ec2e34 and c92a143.

📒 Files selected for processing (2)
  • src/features/party/PartiesProvider.tsx
  • test/e2e/integration/signering-brukerstyrt/delegated-signer-instance-access.ts

Comment thread test/e2e/integration/signering-brukerstyrt/delegated-signer-instance-access.ts Outdated
Ole Martin Handeland added 2 commits July 23, 2026 12:42
Tenor party IDs differ between localtest and TT02, and newly delegated
signing access is not reliable in TT02 due to authorization caching. Those
environment details obscured the frontend regression the test is meant to
protect.

Select the organization by its stable Tenor number and reopen the instance as
its original user. Mock only the instantiation-party response on the second
load so the test isolates the frontend guard while retaining real backend
instance authorization in both environments.
The TT02-compatible regression initially used a Tenor identity that is not
available in localtest, so the test could not validate the fix in both target
environments.

Use Human Andrefiolin and select their organization by its stable organization
number. This keeps the instance authorization real while allowing the same
negative-control test to run in podman and TT02.
@olemartinorg olemartinorg added kind/bug Something isn't working backport This PR should be cherry-picked onto older release branches labels Jul 23, 2026
@olemartinorg
olemartinorg merged commit 39b7921 into main Jul 23, 2026
15 of 16 checks passed
@olemartinorg
olemartinorg deleted the codex/fix-existing-instance-party-check branch July 23, 2026 11:14
@github-actions

Copy link
Copy Markdown
Contributor

Automatic backport successful!

A backport PR has been automatically created for the release/v4.32 release branch.

The release branch release/v4.32 already existed and was updated.

The cherry-pick was clean with no conflicts. Please review the backport PR when it appears.

olemartinorg added a commit that referenced this pull request Jul 23, 2026
* party: allow delegated access without instantiation parties

PartyProvider rejected every authenticated user whose allowed-to-instantiate
party list was empty, even when the URL already identified an existing
instance. This prevented delegated users from opening instances the backend
authorized them to access.

Limit the empty-party error to entry without an instance ID. Cover the
distinction with a signing flow where the signer has real delegated access
while the allowed-to-instantiate response is deliberately empty.

* test: make existing instance access portable to TT02

Tenor party IDs differ between localtest and TT02, and newly delegated
signing access is not reliable in TT02 due to authorization caching. Those
environment details obscured the frontend regression the test is meant to
protect.

Select the organization by its stable Tenor number and reopen the instance as
its original user. Mock only the instantiation-party response on the second
load so the test isolates the frontend guard while retaining real backend
instance authorization in both environments.

* test: use Tenor user shared by localtest and TT02

The TT02-compatible regression initially used a Tenor identity that is not
available in localtest, so the test could not validate the fix in both target
environments.

Use Human Andrefiolin and select their organization by its stable organization
number. This keeps the instance authorization real while allowing the same
negative-control test to run in podman and TT02.

---------

Co-authored-by: Ole Martin Handeland <git@olemartin.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR should be cherry-picked onto older release branches kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App Frontend blocks access to existing instances when user has no party allowed to instantiate

2 participants