Skip to content

[DevPortal] Restructure authentication & authorization configuration - #3045

Merged
Piumal1999 merged 1 commit into
wso2:mainfrom
Piumal1999:auth
Jul 30, 2026
Merged

[DevPortal] Restructure authentication & authorization configuration#3045
Piumal1999 merged 1 commit into
wso2:mainfrom
Piumal1999:auth

Conversation

@Piumal1999

@Piumal1999 Piumal1999 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Purpose

Update the authentication, authorization functionalities according to platform API

Summary

TBD

Approach

TBD

Related PRs

#3022

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR replaces legacy role validation with centralized authorization settings, adds validated role-to-scope expansion, updates authentication and page-tier enforcement, stages component-specific mapping files, aligns scopes and Helm configuration, and revises related documentation.

Changes

Authorization configuration and grant validation

Layer / File(s) Summary
Authorization configuration and grant validation
portals/api-portal/configs/*, portals/api-portal/src/config/*, portals/api-portal/resources/*
Authorization modes, role mappings, startup validation, OpenAPI scope validation, role expansion, and comprehensive configuration tests are added or updated.

Runtime scope and page authorization

Layer / File(s) Summary
Runtime scope and page authorization
portals/api-portal/src/middlewares/*, portals/api-portal/src/controllers/authController.js, portals/api-portal/src/utils/*
Authentication paths derive effective scopes centrally, page access uses admin/subscriber tiers, organization checks are tightened, and retired root/super-admin mappings are removed.

Deployment, packaging, and scope definitions

Layer / File(s) Summary
Deployment, packaging, and scope definitions
kubernetes/helm/*, portals/api-portal/Makefile, portals/api-portal/docker-compose.yaml, portals/api-portal/it/*, portals/api-portal/production/scripts/*
Helm renders authorization settings, distributions stage role mappings, Compose mounts the API Portal mapping, IT uses scope mode, and registered scopes are updated.

Configuration and administration documentation

Layer / File(s) Summary
Configuration and administration documentation
portals/api-portal/README.md, portals/api-portal/distribution/README.md, portals/api-portal/docs/*
Documentation describes role-to-scope files, explicit environment substitutions, claim mappings, authorization modes, page tiers, and revised API Portal links.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant authMiddleware
  participant authorization
  participant roleScopeMap
  Client->>authMiddleware: send authenticated request
  authMiddleware->>authorization: compute effective scopes
  authorization->>roleScopeMap: expand token roles
  roleScopeMap-->>authorization: return granted scopes
  authorization-->>authMiddleware: return authorization context
  authMiddleware-->>Client: allow or reject request
Loading

Suggested reviewers: anugayan, lasanthas, crowleyrajapakse

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description includes Purpose and Related PRs, but most required sections are missing or left as TBD. Fill in Goals, Approach, User stories, Documentation, Automation tests, Security checks, Samples, and Test environment with concrete details.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly matches the main change: restructuring authentication and authorization configuration for DevPortal.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Piumal1999

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 4

🤖 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 `@portals/api-portal/distribution/README.md`:
- Around line 128-132: The authorization configuration table in the README must
match runtime defaults: change the mode default to role, document the default
role-to-scope mapping path instead of an empty value, and update portal_roles to
list only the admin and subscriber tiers, removing super_admin and any
unsupported default tier.

In `@portals/api-portal/docs/administer/asgardeo-setup.md`:
- Around line 107-117: Update the enclosing TOML table from [idp] to
[api_portal.auth.idp] in both
portals/api-portal/docs/administer/asgardeo-setup.md lines 107-117 and
portals/api-portal/docs/administer/authentication.md lines 267-279, leaving the
nested IDP settings unchanged.

In `@portals/api-portal/README.md`:
- Around line 289-292: Update the earlier configuration statement in the README
to remove the claim that every setting supports an APIP_AP_* override; state
instead that overrides apply only to settings whose config.toml entries
explicitly reference the corresponding environment variable, consistent with the
documented templating behavior.
- Around line 258-270: Update the role authorization documentation around the
local auth and role-mode mapping table to state that local role-mode
authorization requires both Platform API’s and the portal’s role-to-scope
mappings. Clarify that Platform API expands roles when issuing the token, while
the portal expands incoming roles when authorization.mode is "role", so
operators must update the relevant entries in both files to change portal
permissions.
🪄 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: 98f9c2e2-81db-406e-b5e9-aff90662b810

📥 Commits

Reviewing files that changed from the base of the PR and between 50ba54b and 4d45f38.

📒 Files selected for processing (29)
  • kubernetes/helm/developer-portal-helm-chart/values-local.yaml
  • kubernetes/helm/developer-portal-ui-helm-chart/templates/configmap.yaml
  • kubernetes/helm/developer-portal-ui-helm-chart/values-local.yaml
  • kubernetes/helm/developer-portal-ui-helm-chart/values.yaml
  • portals/api-portal/Makefile
  • portals/api-portal/README.md
  • portals/api-portal/configs/config-template.toml
  • portals/api-portal/configs/config.toml
  • portals/api-portal/distribution/README.md
  • portals/api-portal/docker-compose.yaml
  • portals/api-portal/docs/README.md
  • portals/api-portal/docs/administer/asgardeo-setup.md
  • portals/api-portal/docs/administer/authentication.md
  • portals/api-portal/it/configs/roles-platform-api-it.yaml
  • portals/api-portal/it/test-config.toml
  • portals/api-portal/production/scripts/register_asgardeo_scopes.sh
  • portals/api-portal/resources/role-to-scope-mapping.yaml
  • portals/api-portal/src/config/authorizationConfig.test.js
  • portals/api-portal/src/config/configDefaults.js
  • portals/api-portal/src/config/configLoader.js
  • portals/api-portal/src/config/roleScopeMap.js
  • portals/api-portal/src/config/roleScopeMap.test.js
  • portals/api-portal/src/controllers/authController.js
  • portals/api-portal/src/middlewares/authMiddleware.js
  • portals/api-portal/src/middlewares/authorization.js
  • portals/api-portal/src/middlewares/ensureAuthenticated.js
  • portals/api-portal/src/middlewares/passportConfig.js
  • portals/api-portal/src/utils/constants.js
  • portals/api-portal/src/utils/jwtDecode.js
💤 Files with no reviewable changes (1)
  • portals/api-portal/src/utils/constants.js

Comment thread portals/api-portal/distribution/README.md
Comment thread portals/api-portal/docs/administer/asgardeo-setup.md
Comment thread portals/api-portal/README.md
Comment thread portals/api-portal/README.md
@Piumal1999
Piumal1999 merged commit c192669 into wso2:main Jul 30, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants