Skip to content

Reimplement auth model to use per-namespace permissions and Quarkus Security#2535

Open
willosborne wants to merge 29 commits into
finos:mainfrom
willosborne:calmhub-auth-rewrite
Open

Reimplement auth model to use per-namespace permissions and Quarkus Security#2535
willosborne wants to merge 29 commits into
finos:mainfrom
willosborne:calmhub-auth-rewrite

Conversation

@willosborne
Copy link
Copy Markdown
Member

Description

Implement a databse-driven entitlements model and authentication framework based on four entitlement levels:

  • read: read resources on a namespace
  • write: create, update and delete resources on a namespace (plus also read)
  • admin: manage entitlements on a namespace (plus also read and write)
  • global admin: create new namespaces

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Code style/formatting changes
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvements
  • ✅ Test additions or updates
  • 🔧 Chore (maintenance, dependencies, CI, etc.)

Affected Components

  • CLI (cli/)
  • Schema (calm/)
  • CALM AI (calm-ai/)
  • CALM Hub (calm-hub/)
  • CALM Hub UI (calm-hub-ui/)
  • CALM Server (calm-server/)
  • CALM Widgets (calm-widgets/)
  • Documentation (docs/)
  • Shared (shared/)
  • VS Code Extension (calm-plugins/vscode/)
  • Dependencies
  • CI/CD

Commit Message Format ✅

Testing

  • I have tested my changes locally
  • I have added/updated unit tests
  • All existing tests pass

Checklist

  • My commits follow the conventional commit format
  • I have updated documentation if necessary
  • I have added tests for my changes (if applicable)
  • My changes follow the project's coding standards

@willosborne willosborne marked this pull request as draft May 28, 2026 15:09
@github-actions github-actions Bot added calm-hub Affects `calm-hub` config labels May 28, 2026
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removing all this since we aren't using scopes any more. OAuth is just to provide the identity of the user.

@willosborne willosborne marked this pull request as ready for review May 29, 2026 17:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reimplements the CalmHub auth model: replaces JWT-scope/PermittedScopes-based RBAC with a per-namespace (and per-domain) entitlements model stored in the DB, enforced via Quarkus @PermissionsAllowed and a custom CalmHubPermissionChecker. Adds a new proxy-auth profile for header-based identity propagation behind an upstream proxy, and a default open no-auth mode driven by calm.hub.no.auth.enabled. Adds domain-scoped user-access management and removes the legacy ResourceType/scope machinery.

Changes:

  • Replace scope-based filter (AccessControlFilter, PermittedScopes, UserAccessValidator.isUserAuthorized) with CalmHubPermissionChecker exposing read/write/admin/global_admin/domain_read/domain_write permissions; update all REST resources and MCP tools to use @PermissionsAllowed / @Authenticated.
  • Introduce three authentication paths: OIDC (secure profile), header-driven ProxyAuthenticationMechanism/ProxyIdentityProvider (proxy-auth), and an open NoAuthAuthenticationMechanism controlled by calm.hub.no.auth.enabled (the new default).
  • Drop ResourceType from UserAccess, add domain field and admin permission, add DomainUserAccessResource and corresponding store APIs, update Keycloak realm and integration tests.

Reviewed changes

Copilot reviewed 88 out of 89 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
calm-hub/src/main/java/org/finos/calm/security/CalmHubPermissionChecker.java New permission checker driving all access decisions from UserAccessStore
calm-hub/src/main/java/org/finos/calm/security/CalmHubScopes.java Replace per-resource scopes with read/write/admin/global_admin/domain_*
calm-hub/src/main/java/org/finos/calm/security/AccessControlFilter.java, PermittedScopes.java, UserRequestAttributes.java Removed — replaced by Quarkus Security permission machinery
calm-hub/src/main/java/org/finos/calm/security/UserAccessValidator.java Trimmed to namespace-set lookup; now also active in proxy-auth
calm-hub/src/main/java/org/finos/calm/security/NoAuthAuthenticationMechanism.java, ProxyAuthenticationMechanism.java, ProxyIdentityProvider.java New authentication mechanisms for no-auth and header-based proxy modes
calm-hub/src/main/java/org/finos/calm/domain/UserAccess.java, UserAction.java Drop ResourceType, add domain + admin permission, introduce UserAction enum
calm-hub/src/main/java/org/finos/calm/store/{UserAccessStore,mongo/MongoUserAccessStore,nitrite/NitriteUserAccessStore}.java Add domain-scoped create/read methods; remove resourceType persistence
calm-hub/src/main/java/org/finos/calm/resources/*.java Replace @PermittedScopes with @PermissionsAllowed/@Authenticated on every endpoint
calm-hub/src/main/java/org/finos/calm/resources/DomainUserAccessResource.java New REST resource for domain-scoped user-access grants
calm-hub/src/main/java/org/finos/calm/mcp/tools/*.java Annotate MCP tool methods with the new permission scopes
calm-hub/src/main/java/org/finos/calm/resources/SearchResource.java Resolve current username from JWT or proxy header for namespace filtering
calm-hub/src/main/resources/application*.properties Add calm.hub.no.auth.enabled (default true), new application-proxy-auth.properties, secure logging defaults
calm-hub/src/test/resources/secure-profile/realm.json Strip per-resource scopes/roles from Keycloak realm
calm-hub/src/integration-test/java/integration/{ProxyAuthIntegration,IntegrationTestProxyAuthProfile,PermittedScopesIntegration,UserAccessGrantsIntegration}.java Rewrite integration tests for DB-driven entitlements; add proxy-auth tests
calm-hub/src/test/java/org/finos/calm/**/*.java Add @TestSecurity(authorizationEnabled=false) to resource tests; new tests for permission checker, proxy/no-auth mechanisms; update store/domain tests for the new shape
calm-hub/PERMISSIONS.md, README.md Document the new entitlement model and profiles
calm-hub/mongo/init-mongo.js Seed grants using the new schema (admin/read, no resourceType)
calm-hub/pom.xml Add quarkus-test-security
package-lock.json Unrelated reclassification of platform-specific deps as dev/peer

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

description = "Creates a timeline for a given namespace with an allocated ID and version 1.0.0"
)
@PermittedScopes({CalmHubScopes.ARCHITECTURES_ALL})
@PermissionsAllowed(CalmHubScopes.READ)
Comment thread calm-hub/README.md

### Secure profile

There are two secure profiles, `secure` and `proxy`.
Comment thread calm-hub/README.md

However, for local testing and development purposes, CalmHub includes a simple pre-configured IdP, Keycloak, that you can spin up locally to simulate a real IdP.

The following sections descibe how to start Keycloak, and how to configure CalmHub to use it correctly.
Comment thread calm-hub/PERMISSIONS.md
| Action | Description |
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `read` | Can read any documents of that type in the namespace. |
| `write` | Can write any documents of that type in the namespace. This includes deleting them. Note that by default resources in CalmHub are immutable, so this usually means 'create' only.
boolean granted =
userAccessStore.getUserAccessForUsername(username)
.stream()
.anyMatch(grant -> "GLOBAL".equals(grant.getNamespace())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calm-hub Affects `calm-hub` config

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants