Skip to content

feat(authorization): add workspace target scopes and resource preview#5

Merged
yacosta738 merged 15 commits into
mainfrom
feature/backend-scopes-execution
May 19, 2026
Merged

feat(authorization): add workspace target scopes and resource preview#5
yacosta738 merged 15 commits into
mainfrom
feature/backend-scopes-execution

Conversation

@yacosta738
Copy link
Copy Markdown
Contributor

Summary

Add workspace target scopes execution and resource preview functionality to the authorization system.

Changes

  • specs: Update authorization, governance, and platform specs
  • feat: Add workspace target scopes and resource preview endpoints
  • refactor: Enhance WorkspaceAuthorizationService with target scope resolution
  • test: Add and update integration tests for new scope functionality

Commits

  • specs: update authorization, governance, and platform specs
  • feat(authorization): add workspace target scopes and resource preview endpoints
  • refactor(authorization): enhance WorkspaceAuthorizationService with target scope resolution
  • test(authorization): add integration tests for resource preview endpoints
  • test(authorization): update existing authorization tests for new scope functionality

Files Changed

  • 3 spec files updated
  • 4 new source files (controllers, queries, infrastructure)
  • 6 modified source files
  • 1 new DB migration
  • 8 test files (3 new, 5 modified)

- README: reflect current repo structure with backend, Biome, openspec
- SECURITY.md: professional security policy with disclosure process,
  CVSS-based response timeline, scope definitions, and attribution
- Frontend (npm): group Astro/Tailwind, auto-merge patches
- Backend (Gradle): group Spring/Kotlin/Testing, auto-merge patches
- GitHub Actions: weekly schedule with auto-merge
- Bazel: manual review for high-risk updates
- Security updates enabled with fix prefix
@dallay-bot
Copy link
Copy Markdown
Contributor

dallay-bot Bot commented May 18, 2026

Hi @yacosta738! 👋

Before we can merge this pull request, the CLA must be signed.

Please leave this exact comment on this PR to complete signing:

I have read the CLA Document and I hereby sign the CLA

Your signature is recorded and linked to your GitHub account. You only need to do this once.

This check is required for all external contributors. Org members bypass this step automatically.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Review Change Stack

Warning

Rate limit exceeded

@yacosta738 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 12 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ae55105d-ea36-449b-98a1-d1ac29beb2e2

📥 Commits

Reviewing files that changed from the base of the PR and between 351506e and 6be1db2.

📒 Files selected for processing (6)
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointPostgresIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/support/AuthorizationEndpointIntegrationTestSupport.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/support/ResourcePreviewEndpointTestBase.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/support/WorkspaceAccessSummaryEndpointTestBase.kt
📝 Walkthrough

Walkthrough

Adds a target-aware workspace scope model, persists per-workspace allowed target IDs, refactors authorization to apply scope-reduction after resolving base permission, exposes GET /api/authorization/resources/{resourceId}/preview, wires an R2DBC scope resolver, updates specs/docs, and adds unit and H2/Postgres integration tests validating allow and deny scenarios.

Changes

Documentation, Specifications, and Configuration

Layer / File(s) Summary
Dependabot configuration and project documentation
.github/dependabot.yml, README.md
Dependabot configuration enables automated dependency updates across npm, Gradle, GitHub Actions, and Bazel with ecosystem-specific schedules and grouping. README refines the platform description, documents the backend server directory and specification folders, and extends development notes with tooling details.
Security policy restructure
SECURITY.md
Security policy rewritten to establish formal vulnerability reporting with a dedicated email contact, checklist, severity-based response timeline, scope definitions, coordinated disclosure guidance, contributor security training requirement, and attribution provisions.
Openspec archives and artifacts
openspec/changes/archive/...
Adds exploration, proposal, design, tasks, verification report, and archived state for the backend-scopes-execution change documenting intent, design, migration, and verification evidence.
Authorization, governance, and platform specification updates
openspec/specs/authorization/spec.md, openspec/specs/governance/spec.md, openspec/specs/platform/spec.md
Specifications formalize the target-aware resource-preview proving capability, require WORKSPACE-context evaluation with explicit targetResourceId, mandate that scopes only reduce existing allow paths, and add explainability scenarios distinguishing scope-caused denials from missing base permissions.

Target-Aware Authorization Scope Implementation

Layer / File(s) Summary
Domain model and authorization contracts
server/smp/src/main/kotlin/com/profiletailors/smp/authorization/domain/AuthorizationModels.kt, server/smp/src/main/kotlin/com/profiletailors/smp/platform/application/PlatformContracts.kt, server/smp/src/main/kotlin/com/profiletailors/smp/authorization/application/GetCurrentWorkspaceAccessSummaryQuery.kt
AuthorizationScope now contains permission, resourceContextType, targetResourceType, and allowedTargetResourceIds. AuthorizationReasonCode gains SCOPE_REDUCED_TARGET. AuthorizationDeniedException.forDecision accepts nullable entitlement key and targetResourceId to format scope-specific denial messages.
Resource preview query and handler
server/smp/src/main/kotlin/com/profiletailors/smp/authorization/application/GetResourcePreviewQuery.kt
Adds GetResourcePreviewQuery and ResourcePreview DTOs and GetResourcePreviewHandler which builds a target-aware ResourceContext, requests detailed authorization for workspace/resource/read, records an authorization audit fact, throws on denial, and returns previewAllowed=true on ALLOW.
HTTP endpoint
server/smp/src/main/kotlin/com/profiletailors/smp/authorization/infrastructure/http/ResourcePreviewController.kt
Adds ResourcePreviewController exposing GET /api/authorization/resources/{resourceId}/preview that dispatches the query through the Mediator.
Authorization service refactor with scope reduction
server/smp/src/main/kotlin/com/profiletailors/smp/authorization/application/WorkspaceAuthorizationService.kt
Refactors decision flow into decideBaseAccess (membership/roles/grants/entitlements) and finalDecision that applies scope-based target reduction only when base decision is ALLOW. Adds resourceContextOverride support and helpers for membership early-deny, scope applicability, and TargetScopeContext.
Scope resolver, database schema, and migrations
server/smp/src/main/kotlin/com/profiletailors/smp/authorization/infrastructure/R2dbcWorkspaceTargetScopeResolver.kt, server/smp/src/main/resources/db/changelog/authorization/007-create-workspace-target-scopes.yaml, server/smp/src/main/resources/db/changelog/db.changelog-master.yaml
Adds R2dbcWorkspaceTargetScopeResolver to query workspace_target_scopes and deserialize allowed_target_ids_json. Adds Liquibase changelog to create workspace_target_scopes with FK constraints, allowed_target_ids_json, unique constraint, and lookup index; includes it in master changelog.
Dependency injection and bean wiring
server/smp/src/main/kotlin/com/profiletailors/smp/authorization/infrastructure/AuthorizationBootstrapConfiguration.kt
Replaces no-op ScopeResolver bean with R2dbcWorkspaceTargetScopeResolver wired with DatabaseClient and ObjectMapper, and adds getResourcePreviewHandler bean wiring GetResourcePreviewHandler with required providers and AuditHook.
Unit and integration test coverage
server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/*, server/smp/src/test/kotlin/com/profiletailors/smp/infrastructure/db/LiquibaseBaselineChangelogTest.kt, server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpoint*Test.kt, server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpoint*Test.kt
Adds GetResourcePreviewHandlerTest (allow + scope-deny cases), extends WorkspaceAuthorizationServiceTest with scope-matching/exclusion/missing-base tests using FixedScopeResolver, updates existing handler tests for signature changes, and adds H2 and PostgreSQL integration tests that seed authoritative state, run Liquibase baseline, call the preview endpoint, and assert HTTP outcomes plus exact AuthorizationDecisionAuditFact entries. Integration tests also ensure workspace_target_scopes does not alter existing workspace-access-summary behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibble specs and seed the scope,
Base permissions checked before the rope,
A preview opens only where allowed,
Audits remember what the code avowed,
Hops of tests keep the rules well-coped.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.72% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding workspace target scopes and resource preview functionality to the authorization system.
Description check ✅ Passed The description clearly outlines the purpose, changes, and scope of the PR with relevant sections covering specs, features, refactoring, and tests.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/backend-scopes-execution

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 and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 18, 2026

Deploying profiletailors with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6be1db2
Status: ✅  Deploy successful!
Preview URL: https://5c2229da.profiletailors-com.pages.dev
Branch Preview URL: https://feature-backend-scopes-execu.profiletailors-com.pages.dev

View logs

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointPostgresIntegrationTest.kt (1)

52-52: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix Detekt LargeClass failure on this integration test class.

CI currently fails on WorkspaceAccessSummaryEndpointPostgresIntegrationTest (LargeClass). Add a class-level suppression (matching the H2 counterpart) or split the suite before merge.

Minimal unblocker
 `@Testcontainers`(disabledWithoutDocker = true)
 `@TestInstance`(TestInstance.Lifecycle.PER_CLASS)
+@Suppress("LargeClass")
 class WorkspaceAccessSummaryEndpointPostgresIntegrationTest(
🤖 Prompt for 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.

In
`@server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointPostgresIntegrationTest.kt`
at line 52, The class WorkspaceAccessSummaryEndpointPostgresIntegrationTest is
tripping Detekt's LargeClass rule; to fix, add a class-level suppression
annotation matching the H2 counterpart (e.g., annotate
WorkspaceAccessSummaryEndpointPostgresIntegrationTest with
`@Suppress`("LargeClass")) or alternatively refactor/split the test methods into
smaller test classes (preserving test setup/fixtures) so the class no longer
violates LargeClass; update imports if needed and ensure the suppression is
applied at the class declaration for
WorkspaceAccessSummaryEndpointPostgresIntegrationTest.
🤖 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 @.github/dependabot.yml:
- Around line 47-48: Remove the unsupported keys "automerge" and
"automerge-type" from .github/dependabot.yml (they appear at the locations
listed) because Dependabot's config schema ignores them; delete those key/value
lines and instead add a GitHub Actions workflow (triggering on pull_request from
Dependabot) that verifies CI and uses the GitHub CLI to run "gh pr merge --auto"
to perform auto-merge.
- Around line 157-162: Remove the invalid top-level "security-updates" block and
move any needed configuration into the valid "updates" structure: delete the
top-level security-updates key and its children (enabled, commit-message) and
instead add equivalent configuration under the "updates" -> "groups" section
using "applies-to: security-updates" and group-level "commit-message" settings;
reference the "security-updates" identifier to remove it and the "updates",
"groups", "applies-to", and "commit-message" keys to place the configuration
correctly.

In `@openspec/specs/authorization/spec.md`:
- Around line 241-249: The spec is self-contradictory: it adds a "Target-Aware
Resource Preview Proving Capability" (resource-preview-by-resourceId, base
permission 'workspace:resource:read') that evaluates a targetResourceId while
elsewhere forbidding new protected endpoints for
/api/authorization/workspace-access/current; reconcile by either (A) explicitly
permitting exactly one new protected endpoint for the new capability (describe
its path and request shape and state that it is the only new protected endpoint
allowed), or (B) remove/modify the new capability text so authorization is
evaluated via the existing /api/authorization/workspace-access/current flow
(remove resource-preview-by-resourceId wording and targetResourceId
requirement). Update the spec sections that reference
/api/authorization/workspace-access/current to reflect the chosen approach so
the document consistently allows the target-aware check and remains testable.

In `@openspec/specs/platform/spec.md`:
- Around line 106-110: The spec is ambiguous about where the new target-aware
proving capability lives: reconcile the conflict between requiring a
target-aware proving capability that uses explicit targetResourceId in WORKSPACE
context (backend-scopes-execution / targetResourceId / WORKSPACE / GLOBAL / USER
/ SYSTEM) and the later claim that the proving slice must remain only
/api/authorization/workspace-access/current; update the spec so it either (A)
explicitly states the existing endpoint
/api/authorization/workspace-access/current is extended to accept an explicit
targetResourceId parameter and perform target-aware evaluation in WORKSPACE
context, or (B) introduces a clearly named new endpoint (e.g.,
/api/authorization/workspace-access/target-aware) for the target-aware proving
capability; ensure the chosen approach is reflected wherever the proving slice
is described and that references to WORKSPACE, GLOBAL, USER, SYSTEM contexts and
the targetResourceId input are consistent.

In `@SECURITY.md`:
- Line 78: The file ends without a final newline; append a single trailing
newline character to the end of SECURITY.md so the last line "For general
security inquiries: **security@profiletailors.com**" is terminated by a newline
(satisfy MD047).

In
`@server/smp/src/main/kotlin/com/profiletailors/smp/authorization/domain/AuthorizationModels.kt`:
- Around line 21-26: Replace the fully qualified type in the AuthorizationScope
data class with a simple import: add an import for ResourceContextType
(com.profiletailors.smp.platform.domain.ResourceContextType) and change the
parameter type in AuthorizationScope (val resourceContextType) from the FQN to
ResourceContextType to match the existing ResourceContext import and improve
consistency.

In
`@server/smp/src/main/kotlin/com/profiletailors/smp/authorization/infrastructure/R2dbcWorkspaceTargetScopeResolver.kt`:
- Around line 60-63: The JSON deserialization in decodeAllowedTargetIds can
throw JsonProcessingException with no context; update it to catch
JsonProcessingException (or JsonParseException) and rethrow a new exception that
includes workspace and principal identifiers so debugging is easier—e.g., change
decodeAllowedTargetIds to accept workspaceId and principalId (or pass them from
the caller in resolveTargetScope/resolve methods), wrap
objectMapper.readValue(...) in a try/catch, and on failure throw an
IllegalStateException (or custom exception) with a message containing
workspaceId, principalId and the rawJson (or a truncated preview) and include
the original exception as the cause to preserve the stacktrace.

In
`@server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/GetResourcePreviewHandlerTest.kt`:
- Around line 23-33: Tests repeat literal IDs and paths (e.g., "principal-1",
"workspace-1", "resource-1", "subject-123"); extract these into private const
val top-level constants and replace repeated occurrences in the test file
(GetResourcePreviewHandlerTest) to satisfy the style gate. Add constants with
clear names like PRINCIPAL_ID, PRINCIPAL_SUBJECT, WORKSPACE_ID, RESOURCE_ID (and
any repeated path strings used across lines 23–152) and update usages in
PrincipalContext, ResourceContext, test setup (CapturingAuditHook/handler
instantiation) and all assertions to reference those constants.

In
`@server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/WorkspaceAuthorizationServiceTest.kt`:
- Around line 38-43: Introduce a test constant for the repeated resource id and
replace all literal occurrences ("resource-1") with that constant; e.g., add a
private val RESOURCE_ID = "resource-1" (or similarly named) at the top of the
test class and update ResourceContext construction in targetAwareResourceContext
and any assertions in WorkspaceAuthorizationServiceTest to use RESOURCE_ID
instead of the literal, ensuring you update all other occurrences mentioned
(lines around 390 and 472) so the tests no longer duplicate the string literal.

In
`@server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpointIntegrationTest.kt`:
- Around line 81-203: Extract repeated literals in
ResourcePreviewEndpointIntegrationTest into private constants (e.g.,
RESOURCE_PREVIEW_PATH = "/api/authorization/resources/%s/preview",
AUTH_HEADER_VALUE = "Bearer valid-token", WORKSPACE_HEADER = "X-Workspace-Id",
WORKSPACE_ID = "workspace-1", PERMISSION_RESOURCE_READ =
"workspace:resource:read", REQUEST_NAME_GET_PREVIEW =
"com.profiletailors.smp.authorization.application.GetResourcePreviewQuery",
PRINCIPAL_ID = "principal-1", ROLE_MEMBER = "member") and replace all inline
usages across the test methods (including calls to webTestClient.get().uri(...),
header(...), expectBody/jsonPath checks, and assertAuthorizationFacts
AuthorizationDecisionAuditFact constructions) with these constants so the path,
headers, token, permission, requestName, principalId, workspaceId and roleKeys
are referenced centrally; keep format specifier for resource id in
RESOURCE_PREVIEW_PATH and use String.format or Kotlin string templates when
building the uri, and update the other occurrences in the file range noted (and
lines 225-281) accordingly.

In
`@server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpointPostgresIntegrationTest.kt`:
- Around line 81-203: The tests duplicate literals (request path
"/api/authorization/resources/resource-1/preview", auth header "Bearer
valid-token", header name "X-Workspace-Id", workspace/principal IDs
"workspace-1"/"principal-1", and the audit requestName
"com.profiletailors.smp.authorization.application.GetResourcePreviewQuery")
across multiple test functions (e.g., allows resource preview..., denies
resource preview..., denies resource preview when base permission is missing...,
scope resolver remains narrow...), causing static-analysis failures; fix by
introducing private constants at the top of the test class (e.g., PREVIEW_URI,
AUTH_TOKEN, WORKSPACE_ID, PRINCIPAL_ID, AUDIT_REQUEST_NAME) and replace all
repeated literal occurrences in the test methods and in the assertions
(including the duplicated block around lines 225-281) to reference these
constants so the suite matches the H2 refactor pattern.

---

Outside diff comments:
In
`@server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointPostgresIntegrationTest.kt`:
- Line 52: The class WorkspaceAccessSummaryEndpointPostgresIntegrationTest is
tripping Detekt's LargeClass rule; to fix, add a class-level suppression
annotation matching the H2 counterpart (e.g., annotate
WorkspaceAccessSummaryEndpointPostgresIntegrationTest with
`@Suppress`("LargeClass")) or alternatively refactor/split the test methods into
smaller test classes (preserving test setup/fixtures) so the class no longer
violates LargeClass; update imports if needed and ensure the suppression is
applied at the class declaration for
WorkspaceAccessSummaryEndpointPostgresIntegrationTest.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 4ee64495-753a-4b3e-a484-1b93e437b45a

📥 Commits

Reviewing files that changed from the base of the PR and between 00e8e22 and 917afae.

📒 Files selected for processing (24)
  • .github/dependabot.yml
  • README.md
  • SECURITY.md
  • openspec/specs/authorization/spec.md
  • openspec/specs/governance/spec.md
  • openspec/specs/platform/spec.md
  • server/smp/src/main/kotlin/com/profiletailors/smp/authorization/application/GetCurrentWorkspaceAccessSummaryQuery.kt
  • server/smp/src/main/kotlin/com/profiletailors/smp/authorization/application/GetResourcePreviewQuery.kt
  • server/smp/src/main/kotlin/com/profiletailors/smp/authorization/application/WorkspaceAuthorizationService.kt
  • server/smp/src/main/kotlin/com/profiletailors/smp/authorization/domain/AuthorizationModels.kt
  • server/smp/src/main/kotlin/com/profiletailors/smp/authorization/infrastructure/AuthorizationBootstrapConfiguration.kt
  • server/smp/src/main/kotlin/com/profiletailors/smp/authorization/infrastructure/R2dbcWorkspaceTargetScopeResolver.kt
  • server/smp/src/main/kotlin/com/profiletailors/smp/authorization/infrastructure/http/ResourcePreviewController.kt
  • server/smp/src/main/kotlin/com/profiletailors/smp/platform/application/PlatformContracts.kt
  • server/smp/src/main/resources/db/changelog/authorization/007-create-workspace-target-scopes.yaml
  • server/smp/src/main/resources/db/changelog/db.changelog-master.yaml
  • server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/GetCurrentWorkspaceAccessSummaryHandlerTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/GetResourcePreviewHandlerTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/WorkspaceAuthorizationServiceTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/infrastructure/db/LiquibaseBaselineChangelogTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpointIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpointPostgresIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointPostgresIntegrationTest.kt

Comment thread .github/dependabot.yml Outdated
Comment thread .github/dependabot.yml Outdated
Comment thread openspec/specs/authorization/spec.md
Comment thread openspec/specs/platform/spec.md
Comment thread SECURITY.md
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
openspec/specs/platform/spec.md (1)

217-223: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify which proving slice line 221 refers to.

Line 221 states "The proving slice MUST remain limited to /api/authorization/workspace-access/current" but the spec now defines two distinct proving slices:

  1. The API-key replacement proving slice at /api/authorization/workspace-access/current (lines 217-223)
  2. The new target-aware scope execution proving slice at /api/authorization/resources/{resourceId}/preview (lines 106-112)

The use of "THE proving slice" (singular) in line 221 creates ambiguity about which slice is being constrained.

📝 Proposed clarification
-The proving slice MUST remain limited to `/api/authorization/workspace-access/current`.
+The API-key replacement proving slice MUST remain limited to `/api/authorization/workspace-access/current`.

Or alternatively, restructure to make the scope clearer:

 For the supported API-key replacement capability, the platform MUST apply one explicit runtime rule: after the replacement operation completes, the successor API key MUST be accepted and the predecessor API key MUST be denied.
 The completed replacement rule MUST NOT allow any overlap window where both predecessor and successor are accepted on `/api/authorization/workspace-access/current`.
-The proving slice MUST remain limited to `/api/authorization/workspace-access/current`.
-The proving slice MUST NOT broaden into new endpoints, service-account rotation, dual-active rollover windows, inventory or detail APIs, or generalized credential-family management.
-The proving slice MUST NOT broaden into broad issuance/admin platform behavior beyond what is minimally necessary to execute one API-key replacement path.
+The API-key replacement proving capability MUST remain limited to `/api/authorization/workspace-access/current`.
+The API-key replacement proving capability MUST NOT broaden into new endpoints, service-account rotation, dual-active rollover windows, inventory or detail APIs, or generalized credential-family management.
+The API-key replacement proving capability MUST NOT broaden into broad issuance/admin platform behavior beyond what is minimally necessary to execute one API-key replacement path.
🤖 Prompt for 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.

In `@openspec/specs/platform/spec.md` around lines 217 - 223, Change the ambiguous
phrase "THE proving slice" to explicitly name the API-key replacement proving
slice and its endpoint: replace "THE proving slice MUST remain limited to
`/api/authorization/workspace-access/current`" with wording such as "The API-key
replacement proving slice for `/api/authorization/workspace-access/current` MUST
remain limited to that endpoint" so it cannot be confused with the target-aware
scope execution proving slice at
`/api/authorization/resources/{resourceId}/preview`; ensure any subsequent
references to "proving slice" likewise specify "API-key replacement proving
slice" when referring to this behavior.
🤖 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 @.github/dependabot.yml:
- Around line 9-13: Each Dependabot update block is missing the required
schedule.interval field; for every schedule block (the YAML key "schedule") add
interval: "weekly" (or your chosen frequency) under schedule so the snippet
becomes schedule: day: "monday" time: "09:00" timezone: "UTC" interval: "weekly"
— apply this change to all four update blocks referenced (also where similar
schedule blocks appear around the other sections).

In `@openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md`:
- Line 141: Update the path string in the change table row so it points to the
archived location: replace the current value
`openspec/changes/backend-scopes-execution/design.md` with the archived path
that includes the `archive/2026-05-18-backend-scopes-execution/` segment (so the
table entry references `archive/2026-05-18-backend-scopes-execution/design.md`),
ensuring the table row in this file (`|
`openspec/changes/backend-scopes-execution/design.md` | Create | ... |`) matches
the actual archived file location for correct traceability.

In `@openspec/specs/platform/spec.md`:
- Around line 106-121: Add a short clarifying sentence immediately after the new
endpoint declaration so readers understand the two proving slices are distinct:
explicitly state that GET /api/authorization/resources/{resourceId}/preview is a
separate, target-aware proving capability evaluated in WORKSPACE context using
the explicit targetResourceId and does not overlap with or extend the proving
slice represented by /api/authorization/workspace-access/current (and therefore
does not affect the API-key replacement proving slice discussed later).

---

Outside diff comments:
In `@openspec/specs/platform/spec.md`:
- Around line 217-223: Change the ambiguous phrase "THE proving slice" to
explicitly name the API-key replacement proving slice and its endpoint: replace
"THE proving slice MUST remain limited to
`/api/authorization/workspace-access/current`" with wording such as "The API-key
replacement proving slice for `/api/authorization/workspace-access/current` MUST
remain limited to that endpoint" so it cannot be confused with the target-aware
scope execution proving slice at
`/api/authorization/resources/{resourceId}/preview`; ensure any subsequent
references to "proving slice" likewise specify "API-key replacement proving
slice" when referring to this behavior.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 23a1f70d-4899-4560-a73e-67d3db6740fe

📥 Commits

Reviewing files that changed from the base of the PR and between 917afae and f0501fa.

📒 Files selected for processing (14)
  • .github/dependabot.yml
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/exploration.md
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/proposal.md
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/specs/authorization/spec.md
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/specs/governance/spec.md
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/specs/platform/spec.md
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/state.yaml
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/tasks.md
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/verify-report.md
  • openspec/specs/authorization/spec.md
  • openspec/specs/platform/spec.md
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpointPostgresIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/WorkspaceAccessSummaryEndpointPostgresIntegrationTest.kt

Comment thread .github/dependabot.yml
Comment thread openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md Outdated
Comment thread openspec/specs/platform/spec.md
@yacosta738 yacosta738 self-assigned this May 19, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 19, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md`:
- Line 373: Add blank lines immediately before and after each subsection heading
that uses four hashes (e.g., "#### Allow: base permission + matching scope" and
the other similar "#### ..." headings flagged in the comment) so there is an
empty line separating headings from surrounding paragraphs (fixes MD022); then
ensure the file ends with exactly one trailing newline character (no extra blank
lines or missing EOF newline) to satisfy MD047.

In
`@server/smp/src/test/kotlin/com/profiletailors/smp/integration/support/ResourcePreviewEndpointTestBase.kt`:
- Around line 332-334: The test JWT in ResourcePreviewEndpointTestBase uses
hard-coded .issuedAt(Instant.parse(...)) and .expiresAt(Instant.parse(...)) that
are already expired; update the JWT construction to use dynamic, non-expired
timestamps (e.g., set .issuedAt(Instant.now()) and
.expiresAt(Instant.now().plus(Duration.ofMinutes(...))) or derive from a test
Clock) so the token remains valid during test execution and avoids brittle auth
failures.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 676c822e-5193-42b1-b0c6-0262487cc737

📥 Commits

Reviewing files that changed from the base of the PR and between f0501fa and 5eaa539.

📒 Files selected for processing (8)
  • .github/dependabot.yml
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md
  • openspec/specs/platform/spec.md
  • server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/GetResourcePreviewHandlerTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/authorization/application/WorkspaceAuthorizationServiceTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpointIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/ResourcePreviewEndpointPostgresIntegrationTest.kt
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/support/ResourcePreviewEndpointTestBase.kt

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md`:
- Around line 324-327: The document leaves undefined the behavior when there is
"no persisted scope row" for a capability; pick and state one deterministic rule
(either "absence = unrestricted within proving capability" or "absence =
deny/require scope presence for scoped principals") and update all places that
reference this behavior (notably the prose around "no persisted scope row" and
the "proving matrix"/"proving capability" sections) to reflect that single rule;
ensure the proving matrix entries and any examples mention the chosen semantics
explicitly and update wording for "scoped principals" and the proving matrix
rows so every decision path deterministically references the chosen rule.

In
`@server/smp/src/test/kotlin/com/profiletailors/smp/integration/support/ResourcePreviewEndpointTestBase.kt`:
- Around line 86-212: Add a test that verifies when the base permission exists
but there is no workspace_target_scopes row the preview is allowed: create a new
test e.g. `allows resource preview when base permission exists and no scope row`
that calls seedMemberWithPreviewPermission() but does NOT call
seedTargetScope(...), then issue the same GET to RESOURCE_PREVIEW_PATH with
BEARER_TOKEN and WORKSPACE_HEADER/WORKSPACE_ID and assert status isOk and
previewAllowed true; finally assert the authorization audit fact (using
GET_RESOURCE_PREVIEW_QUERY, PERMISSION_RESOURCE_READ, PRINCIPAL_ID,
WORKSPACE_ID) records decision ALLOW with reasonCode
AuthorizationReasonCode.ROLE_PERMISSION and roleKeys listOf("member").
🪄 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: ASSERTIVE

Plan: Pro

Run ID: cb72d03b-0151-476b-800c-b0d5e15ad769

📥 Commits

Reviewing files that changed from the base of the PR and between 5eaa539 and 351506e.

📒 Files selected for processing (2)
  • openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md
  • server/smp/src/test/kotlin/com/profiletailors/smp/integration/support/ResourcePreviewEndpointTestBase.kt

Comment thread openspec/changes/archive/2026-05-18-backend-scopes-execution/design.md Outdated
@yacosta738
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
16.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@yacosta738 yacosta738 merged commit 69b7086 into main May 19, 2026
17 of 19 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