Skip to content

Remove resource level permissions from default resources - #4368

Merged
rajithacharith merged 1 commit into
thunder-id:mainfrom
rajithacharith:system-scope-refactor
Jul 27, 2026
Merged

Remove resource level permissions from default resources#4368
rajithacharith merged 1 commit into
thunder-id:mainfrom
rajithacharith:system-scope-refactor

Conversation

@rajithacharith

@rajithacharith rajithacharith commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Purpose

Make the default System resource server ship only the root system scope. The fine-grained system:ou, system:user, system:group, system:usertype (and their :view) scopes are removed from the default (bootstrap) resource set.

Resource-level permissions remain fully supported. The authorization mechanism is unchanged, so:

  • A token with the root system scope can do everything (root satisfies every system:* requirement).
  • A token carrying a resource-level permission (e.g. system:ou:view) still works when an operator declares and grants it.

Approach

  • Bootstrap seed (01-default-resources.yaml): the System resource server now declares only the system resource; the ou/user/group/usertype sub-resources and their view actions were removed. The Administrator role already grants system, and the onboarding flow's requiredScopes: [system:user] is left as-is (a system token satisfies it hierarchically, and a configured system:user token also works).
  • Authorization code is untouched. internal/system/security/permissions.go still maps management APIs to fine-grained permissions; hierarchical matching (HasSufficientPermission) already yields both behaviors above.
  • Integration authz suites (OU/user/group/usertype): since the fine-grained scopes are no longer grantable from the default server (role creation validates permissions against the resource server), each suite now creates a custom resource server that declares the same system:<x>:view hierarchy, grants those to the test role, and binds the token to that resource server via the RFC 8707 resource parameter. All original view-only and OU-scoping assertions are preserved, so the suites now serve as living proof that resource-level permissions still enforce when configured. New testutils helpers: CreateResource, createActionUnderResource, CreateSystemScopedResourceServer, and a resource-indicator override on ObtainAccessTokenWithPassword.
  • Advertised default scopes trimmed (kept system): Console config.js, Helm values, OpenChoreo template/sample/README, and the trusted-issuer / configuration docs.

Related Issues

  • N/A

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Updated trusted-issuer and configuration docs)
  • Tests provided.
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • Configuration
    • Simplified default Console OAuth scopes by removing granular system:* permissions, leaving a reduced set.
    • Updated Helm/runtime and sample configuration examples to match the streamlined scope list.
    • Adjusted default server bootstrapping so the system resource server includes only the core System resource.
  • Documentation
    • Updated security and trusted-issuer documentation examples to reflect the reduced scopes/prefix examples.
  • Bug Fixes
    • Improved authorization integration tests by switching to dedicated scoped resource servers for fine-grained system:* checks.

@rajithacharith rajithacharith added the trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7be63dc1-2264-483e-b192-e80deaddf09d

📥 Commits

Reviewing files that changed from the base of the PR and between aa1e244 and 1c09853.

📒 Files selected for processing (9)
  • backend/cmd/server/bootstrap/01-default-resources.yaml
  • docs/content/deployment/configuration.mdx
  • docs/content/guides/trusted-issuer.mdx
  • frontend/apps/console/public/config.js
  • install/helm/values.yaml
  • install/openchoreo/thunderid-oc-resourcetype/README.md
  • install/openchoreo/thunderid-oc-resourcetype/samples/resource.yaml
  • install/openchoreo/thunderid-oc-resourcetype/templates/thunderid-resourcetype.yaml
  • tests/integration/group/group_authz_test.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • install/openchoreo/thunderid-oc-resourcetype/README.md
  • install/openchoreo/thunderid-oc-resourcetype/samples/resource.yaml
  • install/helm/values.yaml
  • docs/content/guides/trusted-issuer.mdx
  • docs/content/deployment/configuration.mdx
  • install/openchoreo/thunderid-oc-resourcetype/templates/thunderid-resourcetype.yaml
  • tests/integration/group/group_authz_test.go

📝 Walkthrough

Walkthrough

The change removes granular system scopes and bootstrap resources, adds utilities for custom system-scoped resource servers, and updates group, OU, user, and user-type authorization tests to use resource-bound tokens and cleanup.

Changes

Scoped system authorization

Layer / File(s) Summary
Bootstrap and OAuth scope contracts
backend/cmd/server/bootstrap/..., docs/content/..., frontend/apps/console/..., install/helm/..., install/openchoreo/...
The default System resource server and Console OAuth scope lists now omit granular system:* scopes.
Scoped resource server test utilities
tests/integration/testutils/api_utils.go, tests/integration/testutils/oauth2_utils.go
Test helpers create hierarchical system-scoped resources and actions, and token acquisition accepts an optional resource binding.
Group and OU authorization setup
tests/integration/group/..., tests/integration/ou/...
Authorization suites create scoped resource servers, use them for permissions and tokens, and remove them during teardown.
User and user-type authorization setup
tests/integration/user/..., tests/integration/usertype/...
User-related authorization suites use custom scoped resource servers and resource-bound tokens with teardown cleanup.

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

Sequence Diagram(s)

sequenceDiagram
  participant AuthzSuite
  participant ResourceServerHelpers
  participant ThunderID
  participant OAuthFlow
  AuthzSuite->>ResourceServerHelpers: create scoped resource server
  ResourceServerHelpers->>ThunderID: create resources and View actions
  AuthzSuite->>ThunderID: assign role permissions
  AuthzSuite->>OAuthFlow: request token with scoped resource identifier
  OAuthFlow-->>AuthzSuite: return resource-bound access token
Loading

Possibly related PRs

  • thunder-id/thunderid#2487: Both changes update authorization integration tests to use custom system-scoped resource servers instead of relying on the bootstrap-seeded System server.

Suggested reviewers: donomalvindula, ayeshajay, brionmario, jeradrutnam, dilusha-madushan

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing default resource-level permissions from the System resource server.
Description check ✅ Passed The description follows the template with Purpose, Approach, Related Issues/PRs, Checklist, and Security checks filled in.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Trivy (0.72.0)

Trivy execution failed: 2026-07-27T09:16:46Z FATAL Fatal error run error: fs scan error: scan error: scan failed: failed analysis: post analysis error: post analysis error: kubernetes scan error: fs filter error: fs filter error: walk error range error: stat frontend/apps/console/doctor.config.json: no such file or directory: range error: stat frontend/apps/console/doctor.config.json: no such file or directory

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

docs/content/deployment/configuration.mdx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

docs/content/guides/trusted-issuer.mdx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

frontend/apps/console/public/config.js

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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: 3

🤖 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 `@install/helm/values.yaml`:
- Line 204: Preserve the group scope in all OpenChoreo Console scope defaults:
update install/helm/values.yaml:204,
install/openchoreo/thunderid-oc-resourcetype/README.md:359,
install/openchoreo/thunderid-oc-resourcetype/samples/resource.yaml:132, and
install/openchoreo/thunderid-oc-resourcetype/templates/thunderid-resourcetype.yaml:220
so each default or example includes group.

In `@install/openchoreo/thunderid-oc-resourcetype/README.md`:
- Line 359: Update the runtime.console.scopes documentation entry in the README
to replace the em dash with an approved alternative such as a period, comma, or
rephrased wording, while preserving the existing meaning and default scope
value.

In `@tests/integration/testutils/api_utils.go`:
- Around line 1542-1556: Update the resource-creation error paths in the helper
containing the CreateResource and createActionUnderResource calls to capture
DeleteResourceServer failures instead of discarding them. Add a shared rollback
helper for these branches that combines the original creation error with the
cleanup error, while preserving the existing cleanup behavior and contextual
error messages.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 88eb5fa2-e96d-494a-b09f-1ce2b0a486dd

📥 Commits

Reviewing files that changed from the base of the PR and between ef960bc and 98673dc.

📒 Files selected for processing (14)
  • backend/cmd/server/bootstrap/01-default-resources.yaml
  • docs/content/deployment/configuration.mdx
  • docs/content/guides/trusted-issuer.mdx
  • frontend/apps/console/public/config.js
  • install/helm/values.yaml
  • install/openchoreo/thunderid-oc-resourcetype/README.md
  • install/openchoreo/thunderid-oc-resourcetype/samples/resource.yaml
  • install/openchoreo/thunderid-oc-resourcetype/templates/thunderid-resourcetype.yaml
  • tests/integration/group/group_authz_test.go
  • tests/integration/ou/ou_authz_test.go
  • tests/integration/testutils/api_utils.go
  • tests/integration/testutils/oauth2_utils.go
  • tests/integration/user/user_authz_test.go
  • tests/integration/usertype/usertype_authz_test.go
💤 Files with no reviewable changes (2)
  • frontend/apps/console/public/config.js
  • backend/cmd/server/bootstrap/01-default-resources.yaml

Comment thread install/helm/values.yaml Outdated
Comment thread install/openchoreo/thunderid-oc-resourcetype/README.md Outdated
Comment thread tests/integration/testutils/api_utils.go Outdated
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@rajithacharith
rajithacharith force-pushed the system-scope-refactor branch 2 times, most recently from ae721d0 to aa1e244 Compare July 27, 2026 08:28
@rajithacharith rajithacharith added trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes and removed trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes labels Jul 27, 2026
@rajithacharith
rajithacharith force-pushed the system-scope-refactor branch from aa1e244 to 1c09853 Compare July 27, 2026 09:14
@rajithacharith
rajithacharith enabled auto-merge July 27, 2026 09:31
@rajithacharith
rajithacharith added this pull request to the merge queue Jul 27, 2026
Merged via the queue into thunder-id:main with commit 9f9adf2 Jul 27, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes Type/Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants