Repository navigation
Portal OIDC Authentication and Authorisation - #66
anjuchamantha merged 13 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
1b878c9 to
c3fce08
Compare
eb799bc to
fc6bcd6
Compare
- Enable credentialed CORS for the split-cookie setup in example config. - Require HTTPS for production authentication URLs. - Display logout errors on failure
- Production CSP with exact BFF connect-src - Inline/eval scripts prohibited - object-src, base-uri, frame-ancestors, form-action, and security headers configured - Build emits dist/_headers and an enforcing CSP meta fallback - Production build rejects inline scripts, handlers, styles, unsafe DOM sinks, web storage, and console logging - Logout navigation now uses an explicit origin allowlist - Direct dependencies pinned - Production dependency audit added to CI Deferred - Replacing style-src 'unsafe-inline' with Emotion style nonces or build-time styling
- `/auth/login` now generates random state and PKCE verifier values. - Sends an S256 `code_challenge`. - Stores state/verifier in short-lived HttpOnly cookies. - `/auth/callback` validates state in constant time. - Transaction cookies are consumed before code exchange, preventing replay. - Token exchange sends the matching `code_verifier`. - No server session, shared storage, encryption key, or signing key was introduced. - Configuration, `.env.example`, OpenAPI, implementation plan, unit tests, and integration tests were updated. - OIDC nonce remains deferred. - Update plan documentation
- Document the authentication toggle and split-cookie variables. - Malformed logout allowlist entries are now skipped individually while valid origins remain usable. - Added regression coverage for mixed valid and invalid origins. - Vite now uses one fallback-safe `apiBaseURL` for HTTPS detection and both CSP policies. - Production and development still require an explicitly configured API URL; only test mode uses the fallback.
fc6bcd6 to
e1da421
Compare
| go 1.26.3 | ||
|
|
||
| require ( | ||
| github.com/coreos/go-oidc/v3 v3.20.0 |
There was a problem hiding this comment.
Are these commonly used dependencies? Can you check the other dependencies wso2 go projects have used?
There was a problem hiding this comment.
Let's create an issue to check the dependencies used.
Purpose
Add production-ready authentication and authorization to the portal. This introduces OIDC login, session refresh, scoped access control, CSP, and logout. Supports OAuth & OIDC compliant identity providers. Tested with both Asgardeo and ThunderID v.0.47.0.
Goals
Approach
Backend
GET /auth/loginGET /auth/callbackPOST /auth/refreshPOST /auth/logoutHttpOnlytransaction cookies.HttpOnlycookie./meand generic/apiroutes.userIdandorg-idvalues from the validated principal.404.Authorizationheader.Frontend
401, one request retry, and login redirection when refresh fails.User stories
Release note
Added OIDC authentication, split-token session protection, scoped portal authorization, session refresh, secure logout, a user-profile menu, and production browser-security headers.
Documentation
Updated:
portal/backend/README.mdportal/backend/.env.exampleportal/backend/openapi/portal-backend.yamlportal/frontend/README.mdportal/frontend/.env.exampleAutomation tests
Unit tests
Integration tests
go test ./...passed.pnpm lintpassed.pnpm testpassed.pnpm buildpassed.Security checks
Reference
[1] - Split cookie pattern in APIM portals
[2] - Split cookie pattern in OB3 portals
[3] - Avoiding cookies being read by JavaScript and other client-side scripts [Security Guidelines]
[4] - Double submit pattern [Security Guidelines]
Related PRs
Migrations
No database migration is required.
Deployment configuration must be updated before enabling authentication:
BFF_AUTH__CLIENT_SECRETthrough the runtime environment only.BFF_AUTH__ENABLED=true.BFF_AUTH__COOKIE_SECURE=true.dist/_headersfile.Test environment
Learning
This implementation applies a BFF split-token pattern so neither browser-readable storage nor an
HttpOnlycookie contains a complete access or refresh token. It also uses OIDC discovery and JWKS validation, OAuth state protection, PKCE, strict route-to-scope mapping, constrained logout navigation, and deployment-generated browser-security headers.