Skip to content

Backend agent table public permissions - #1865

Merged
Artuomka merged 2 commits into
mainfrom
backend_agent_table_public_permissions
Aug 5, 2026
Merged

Backend agent table public permissions#1865
Artuomka merged 2 commits into
mainfrom
backend_agent_table_public_permissions

Conversation

@Artuomka

@Artuomka Artuomka commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added site runtime policy management for configuring site authorization rules.
    • Added safeguards preventing public access grants to authentication tables and credential fields.
    • Added configurable end-user token expiration, defaulting to 24 hours.
    • Added optional user identifiers to end-user tokens for more precise authorization.
  • Bug Fixes

    • Invalid policies and unauthorized policy updates are now rejected with clear errors.
  • Tests

    • Added coverage for policy storage, authorization, protected fields, and invalid requests.

Copilot AI review requested due to automatic review settings August 5, 2026 11:35
@Artuomka
Artuomka enabled auto-merge August 5, 2026 11:35
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The PR adds nullable connection-level site runtime policies, an authorized agents endpoint to replace them, Sitenova response and token contract updates, and safeguards against public grants on configured authentication data.

Site runtime policy

Layer / File(s) Summary
Policy persistence
backend/src/common/data-injection.tokens.ts, backend/src/entities/connection/..., backend/src/migrations/...
Connections store nullable runtime policies in a JSONB column. Repository methods read and replace the policy.
Policy write API
backend/src/microservices/agents-microservice/...
The new endpoint validates object policies, checks connection:edit authorization, stores the complete policy, and returns it.
Sitenova runtime contract
backend/src/microservices/sitenova-microservice/...
Connection responses expose the policy. End-user tokens accept an optional uid, and token TTL uses ENDUSER_TOKEN_TTL with a 24h default.
Protected public grants
backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts, backend/test/...
Public grants on the configured auth table or password column are rejected. E2E tests cover storage, authorization, validation, and unrelated grants.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant AgentsController
  participant SetSiteRuntimePolicyUseCase
  participant Cedar
  participant ConnectionRepository
  Client->>AgentsController: Submit site runtime policy
  AgentsController->>SetSiteRuntimePolicyUseCase: Pass user, connection, and policy
  SetSiteRuntimePolicyUseCase->>Cedar: Check connection:edit
  SetSiteRuntimePolicyUseCase->>ConnectionRepository: Replace stored policy
  ConnectionRepository-->>SetSiteRuntimePolicyUseCase: Return persisted policy
  SetSiteRuntimePolicyUseCase-->>AgentsController: Return SiteRuntimePolicyRO
  AgentsController-->>Client: Return policy response
Loading

Possibly related PRs

Suggested reviewers: copilot, lyubov-voloshko

Poem

A rabbit stores the policy bright,
Checks Cedar before the write.
Auth tables guard the gate,
Tokens carry IDs in state.
JSON fields now hop and flow—
Safe grants bloom where permissions grow.

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Security Check ⚠️ Warning The auth-table safeguard checks only newly requested tables; a caller can grant the auth table before setting the policy, then the policy write leaves that public Cedar grant active. When writing or replacing a policy, inspect and remove/reject conflicting existing public grants. Also validate the complete effective grant set, including the legacy public-permissions route.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the backend agent changes for table public permissions, which is the main functional purpose of the pull request.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_agent_table_public_permissions

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 requested a review from lyubov-voloshko August 5, 2026 11:36

Copilot AI 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.

Pull request overview

This PR adds support for storing a per-connection “site runtime policy” (manifest/data contract) for generated sites, exposes it to the SiteNova internal credentials response, and enforces new safety rules that prevent public (anonymous) reads from being granted on the site’s auth/visitor-accounts table and credential column.

Changes:

  • Add site_runtime_policy (jsonb) to connection, with repository methods to read/write it.
  • Add an internal agents endpoint to write the runtime policy (manifest) after re-checking connection:edit (Cedar).
  • Enforce refusal of public-read grants targeting the manifest’s auth table or credential column, and add e2e coverage for the new policy write + refusal behavior.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
backend/test/ava-tests/non-saas-tests/non-saas-agents-microservice-public-permissions-e2e.test.ts Adds e2e tests for writing the runtime manifest and refusing unsafe public grants.
backend/src/migrations/1785915298819-AddSiteRuntimePolicyToConnection.ts Adds site_runtime_policy jsonb column to connection.
backend/src/microservices/sitenova-microservice/use-cases/sitenova-get-connection.use.case.ts Includes siteRuntimePolicy in internal connection credentials response.
backend/src/microservices/sitenova-microservice/services/sitenova-enduser-auth.service.ts Extends end-user token signing to optionally include uid claim; aligns JWT TTL typing.
backend/src/microservices/sitenova-microservice/data-structures/sitenova-site.ds.ts Reads end-user token TTL from ENDUSER_TOKEN_TTL with 24h default; adds optional uid to payload.
backend/src/microservices/sitenova-microservice/data-structures/sitenova-internal-responses.ds.ts Documents/exports optional siteRuntimePolicy field on the internal response DTO.
backend/src/microservices/agents-microservice/use-cases/set-site-runtime-policy.use.case.ts New use case that validates and stores the runtime policy on the connection with audit logging.
backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts Adds refusal logic preventing public grants on the manifest auth table / credential column.
backend/src/microservices/agents-microservice/use-cases/agents-use-cases.interface.ts Adds ISetSiteRuntimePolicy interface.
backend/src/microservices/agents-microservice/dto/agents-site-runtime-policy.dtos.ts New DTO for the policy write endpoint.
backend/src/microservices/agents-microservice/data-structures/agents.ds.ts Adds DS for policy write use case.
backend/src/microservices/agents-microservice/data-structures/agents-responses.ds.ts Adds response object for policy write endpoint.
backend/src/microservices/agents-microservice/agents.module.ts Wires new use case provider into the agents module.
backend/src/microservices/agents-microservice/agents.controller.ts Adds POST endpoint to set site runtime policy.
backend/src/exceptions/text/messages.ts Adds new validation/refusal messages for policy/object validation and unsafe grants.
backend/src/entities/connection/repository/custom-connection-repository-extension.ts Adds repository methods to get/update site_runtime_policy.
backend/src/entities/connection/repository/connection.repository.interface.ts Extends repository interface with site runtime policy methods.
backend/src/entities/connection/connection.entity.ts Adds site_runtime_policy jsonb column mapping.
backend/src/common/data-injection.tokens.ts Adds DI token for the new agents use case.
Suppressed comments (1)

backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts:117

  • refuseGrantOnSiteAuthTable returns early when authTable is missing, which also disables the credential-column check. If a stored policy is malformed/partial (e.g., passwordField present but tableName missing), public grants that include the credential column won’t be refused even though the comment says the password column should be blocked wherever it appears.
		if (!authTable) {
			return;
		}

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

Comment on lines +83 to 87
await this.refuseGrantOnSiteAuthTable(connectionId, userId, tables);

let effective: Array<IPublicTablePermission> = tables;
if (mode !== 'replace') {
const existing = await this.cedarAuthService.getPublicPermissions(connectionId);
@Artuomka
Artuomka merged commit 8ec0bc2 into main Aug 5, 2026
16 of 18 checks passed
@Artuomka
Artuomka deleted the backend_agent_table_public_permissions branch August 5, 2026 11:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (5)
backend/test/ava-tests/non-saas-tests/non-saas-agents-microservice-public-permissions-e2e.test.ts (1)

226-233: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use an arrow function for siteRuntimePolicyRequest.

As per coding guidelines: “Prefer arrow functions over function declarations.”

Proposed refactor
-function siteRuntimePolicyRequest(connectionId: string, body: Record<string, unknown>): request.Test {
-	return request(app.getHttpServer())
+const siteRuntimePolicyRequest = (connectionId: string, body: Record<string, unknown>): request.Test =>
+	request(app.getHttpServer())
 		.post(`/internal/agents/connection/site-runtime-policy/${connectionId}`)
 		.send(body)
 		.set('Authorization', microserviceAuthHeader())
 		.set('Content-Type', 'application/json')
 		.set('Accept', 'application/json');
-}
🤖 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
`@backend/test/ava-tests/non-saas-tests/non-saas-agents-microservice-public-permissions-e2e.test.ts`
around lines 226 - 233, Convert siteRuntimePolicyRequest from a function
declaration to an arrow function while preserving its parameters, return type,
request construction, and chaining behavior.

Source: Coding guidelines

backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts (1)

112-112: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use an interface for the policy auth shape.

Move the inline object shape to a named interface. As per coding guidelines: “Use interfaces for object shapes and type for unions and primitives.”

Proposed refactor
+interface SiteRuntimePolicyAuth {
+	tableName?: unknown;
+	passwordField?: unknown;
+}
+
-		const auth = policy?.auth as { tableName?: unknown; passwordField?: unknown } | undefined;
+		const auth = policy?.auth as SiteRuntimePolicyAuth | undefined;
🤖 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
`@backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts`
at line 112, Define a named interface for the policy auth object shape
containing the optional tableName and passwordField properties, then replace the
inline assertion in the policy permission logic with that interface. Keep the
existing optionality and unknown property types unchanged.

Source: Coding guidelines

backend/src/microservices/sitenova-microservice/data-structures/sitenova-internal-responses.ds.ts (1)

69-72: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace string concatenation with template literals.

  • backend/src/microservices/sitenova-microservice/data-structures/sitenova-internal-responses.ds.ts#L69-L72: Use one multiline template literal for the Swagger description.
  • backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts#L122-L124: Use one template literal for the refusal log message.

As per coding guidelines: “Use template literals instead of string concatenation.”

🤖 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
`@backend/src/microservices/sitenova-microservice/data-structures/sitenova-internal-responses.ds.ts`
around lines 69 - 72, Replace the concatenated Swagger description in the
response contract with a single multiline template literal, preserving its text
and whitespace. Also update the refusal log message in
setPublicPermissionsUseCase to use one template literal instead of string
concatenation; apply the change in both specified files.

Source: Coding guidelines

backend/src/microservices/agents-microservice/dto/agents-site-runtime-policy.dtos.ts (1)

13-16: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use template literals for the changed multi-line strings.

  • backend/src/microservices/agents-microservice/dto/agents-site-runtime-policy.dtos.ts#L13-L16: Replace the concatenated Swagger description with one template literal.
  • backend/src/microservices/agents-microservice/use-cases/set-site-runtime-policy.use.case.ts#L63-L65: Use one template literal for the audit log message.
  • backend/src/microservices/agents-microservice/agents.controller.ts#L137-L140: Replace the concatenated Swagger description with one template literal.

As per coding guidelines: “Use template literals instead of string concatenation.”

🤖 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
`@backend/src/microservices/agents-microservice/dto/agents-site-runtime-policy.dtos.ts`
around lines 13 - 16, Replace the concatenated multi-line strings with single
template literals at agents-site-runtime-policy.dtos.ts lines 13-16 and
agents.controller.ts lines 137-140, preserving their existing text. Update the
audit log message at set-site-runtime-policy.use.case.ts lines 63-65 similarly,
preserving its current content and behavior.

Source: Coding guidelines

backend/src/entities/connection/connection.entity.ts (1)

128-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace Record<string, any> with a shared policy type.

site_runtime_policy is a security-relevant runtime contract. any removes type checking and differs from the repository's Record<string, unknown> contract. Define a shared SiteRuntimePolicy interface and use it across the entity, repository, DTO, and response types. Use an index signature with unknown if extension keys are required.

As per coding guidelines: “Avoid any types - use specific types or generics instead” and “Use interfaces for object shapes and type for unions and primitives.”

🤖 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 `@backend/src/entities/connection/connection.entity.ts` around lines 128 - 131,
Replace the site_runtime_policy Record<string, any> annotation in the connection
entity with a shared SiteRuntimePolicy interface, defining extension keys with
unknown where needed. Reuse this interface consistently across the related
entity, repository, DTO, and response types, preserving nullable and optional
behavior while eliminating any.

Source: Coding guidelines

🤖 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
`@backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts`:
- Around line 120-121: Update the permission validation around
namesPasswordColumn in the public-grant flow to reject wildcard or omitted
readableColumns whenever the site policy defines passwordField, since those
grants include every column. Preserve the existing explicit password-column and
auth-table checks, while allowing grants only when their expanded columns cannot
expose the configured credential field.

In
`@backend/src/microservices/sitenova-microservice/data-structures/sitenova-site.ds.ts`:
- Around line 9-10: Validate ENDUSER_TOKEN_TTL when initializing
SITENOVA_ENDUSER_TOKEN_TTL, accepting only durations supported by jwt.sign and
rejecting bare numeric or invalid values. Fail configuration loading immediately
with a clear error instead of allowing invalid TTLs to reach token-signing code.

---

Nitpick comments:
In `@backend/src/entities/connection/connection.entity.ts`:
- Around line 128-131: Replace the site_runtime_policy Record<string, any>
annotation in the connection entity with a shared SiteRuntimePolicy interface,
defining extension keys with unknown where needed. Reuse this interface
consistently across the related entity, repository, DTO, and response types,
preserving nullable and optional behavior while eliminating any.

In
`@backend/src/microservices/agents-microservice/dto/agents-site-runtime-policy.dtos.ts`:
- Around line 13-16: Replace the concatenated multi-line strings with single
template literals at agents-site-runtime-policy.dtos.ts lines 13-16 and
agents.controller.ts lines 137-140, preserving their existing text. Update the
audit log message at set-site-runtime-policy.use.case.ts lines 63-65 similarly,
preserving its current content and behavior.

In
`@backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts`:
- Line 112: Define a named interface for the policy auth object shape containing
the optional tableName and passwordField properties, then replace the inline
assertion in the policy permission logic with that interface. Keep the existing
optionality and unknown property types unchanged.

In
`@backend/src/microservices/sitenova-microservice/data-structures/sitenova-internal-responses.ds.ts`:
- Around line 69-72: Replace the concatenated Swagger description in the
response contract with a single multiline template literal, preserving its text
and whitespace. Also update the refusal log message in
setPublicPermissionsUseCase to use one template literal instead of string
concatenation; apply the change in both specified files.

In
`@backend/test/ava-tests/non-saas-tests/non-saas-agents-microservice-public-permissions-e2e.test.ts`:
- Around line 226-233: Convert siteRuntimePolicyRequest from a function
declaration to an arrow function while preserving its parameters, return type,
request construction, and chaining behavior.
🪄 Autofix

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

Plan: Pro Plus

Run ID: b5eb16e3-ea56-47f1-bf3b-cc00b9b93e99

📥 Commits

Reviewing files that changed from the base of the PR and between 24d01cb and 5c6d6cc.

📒 Files selected for processing (19)
  • backend/src/common/data-injection.tokens.ts
  • backend/src/entities/connection/connection.entity.ts
  • backend/src/entities/connection/repository/connection.repository.interface.ts
  • backend/src/entities/connection/repository/custom-connection-repository-extension.ts
  • backend/src/exceptions/text/messages.ts
  • backend/src/microservices/agents-microservice/agents.controller.ts
  • backend/src/microservices/agents-microservice/agents.module.ts
  • backend/src/microservices/agents-microservice/data-structures/agents-responses.ds.ts
  • backend/src/microservices/agents-microservice/data-structures/agents.ds.ts
  • backend/src/microservices/agents-microservice/dto/agents-site-runtime-policy.dtos.ts
  • backend/src/microservices/agents-microservice/use-cases/agents-use-cases.interface.ts
  • backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts
  • backend/src/microservices/agents-microservice/use-cases/set-site-runtime-policy.use.case.ts
  • backend/src/microservices/sitenova-microservice/data-structures/sitenova-internal-responses.ds.ts
  • backend/src/microservices/sitenova-microservice/data-structures/sitenova-site.ds.ts
  • backend/src/microservices/sitenova-microservice/services/sitenova-enduser-auth.service.ts
  • backend/src/microservices/sitenova-microservice/use-cases/sitenova-get-connection.use.case.ts
  • backend/src/migrations/1785915298819-AddSiteRuntimePolicyToConnection.ts
  • backend/test/ava-tests/non-saas-tests/non-saas-agents-microservice-public-permissions-e2e.test.ts

Comment on lines +120 to +121
const namesPasswordColumn = Boolean(passwordField && table.readableColumns?.includes(passwordField));
if (namesAuthTable || namesPasswordColumn) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Locate relevant files"
fd -a 'set-public-permissions.use.case.ts|cedar-policy-generator.ts|agents-use-cases.interface.ts|agents-.*\.ds.ts|agents-.*\.ds$.|agents-responses.ds.ts' backend/src || true

echo
echo "Search for SetPublicPermissionsDs definition/usages"
rg -n "SetPublicPermissionsDs|SetPublicPermissions|set-public-permissions|readableColumns|passwordField|authTable" backend/src -S | head -200

echo
echo "Inspect target use-case lines"
cat -n backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts | sed -n '1,180p'

echo
echo "Inspect public permission interface"
cat -n backend/src/entities/cedar-authorization/cedar-policy-generator.ts | sed -n '1,120p'

Repository: rocket-admin/rocketadmin

Length of output: 27009


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Inspect public permissions persistence/validation"
cat -n backend/src/entities/cedar-authorization/cedar-authorization.service.ts | sed -n '300,430p'
cat -n backend/src/microservices/agents-microservice/data-structures/agents.ds.ts | sed -n '1,80p'
cat -n backend/src/microservices/agents-microservice/data-structures/agents-responses.ds.ts | sed -n '1,70p'
cat -n backend/src/microservices/agents-microservice/data-structures/agents.use.cases.interface.ts | sed -n '1,90p'

echo
echo "Search for table metadata calls from agents use case or controller"
rg -n "getConnectionTable|getTable|connectionTable|structure|columns|getReadableColumns|set_public_read_permissions|SetPublicPermissionsDto|SetPublicPermissionsDs" backend/src/microservices/agents-microservice backend/src/entities/cedar-authorization -S

Repository: rocket-admin/rocketadmin

Length of output: 9646


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Agents use-case interface"
cat -n backend/src/microservices/agents-microservice/use-cases/agents-use-cases.interface.ts | sed -n '1,90p'

echo
echo "Agents controller relevant flow"
cat -n backend/src/microservices/agents-microservice/agents.controller.ts | sed -n '1,120p'

echo
echo "Validation helpers and policy references"
cat -n backend/src/entities/cedar-authorization/cedar-authorization.service.ts | sed -n '430,540p'
cat -n backend/src/entities/cedar-authorization/cedar-authorization.service.ts | sed -n '1,120p'

echo
echo "Target path and deterministic behavior probe from source text"
python3 - <<'PY'
import pathlib, re

p = pathlib.Path('backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts')
s = p.read_text()

checks = [
  ('refuseGrantOnSiteAuthTable checks existing requests only', re.search(r'for\s+const\s+table\s+of\s+tables\s*\{', s) is not None),
  ('passwordField check only through explicit readableColumns includes', bool(re.search(r'Boolean\(passwordField\s*&&\s*table\.readableColumns\?\.includes\(passwordField\)\)', s))),
  ('wildcard/empty readableColumns expands to all columns in generator', bool(re.search(r'else\s*\{\s*policies\.push\(\s*`permit\(\n\s*principal,\n\s*action\s*==\s*RocketAdmin::Action::"column:read",\n\s*resource\s+in\s+\$\{tableRef\}\n\);', s))),
]
for name, ok in checks:
    print(f'{name}: {ok}')
PY

Repository: rocket-admin/rocketadmin

Length of output: 19972


Sensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor

Reachability: Internal

Reachability path
● Entry
  backend/src/microservices/agents-microservice/agents.module.ts:42
  SetPublicPermissionsUseCase
│
▼
● Sink
  backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts

Block wildcard public grants that can include the password field.

readableColumns omitted or empty generates an all-column public grant. The current check only rejects an explicit passwordField entry, so a non-auth table containing that credential field can still be exposed. Expand readableColumns before this check, or reject wildcard grants while a site policy defines passwordField.

🤖 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
`@backend/src/microservices/agents-microservice/use-cases/set-public-permissions.use.case.ts`
around lines 120 - 121, Update the permission validation around
namesPasswordColumn in the public-grant flow to reject wildcard or omitted
readableColumns whenever the site policy defines passwordField, since those
grants include every column. Preserve the existing explicit password-column and
auth-table checks, while allowing grants only when their expanded columns cannot
expose the configured credential field.

Comment on lines +9 to +10
export const SITENOVA_ENDUSER_TOKEN_TTL =
process.env.ENDUSER_TOKEN_TTL && process.env.ENDUSER_TOKEN_TTL.length > 0 ? process.env.ENDUSER_TOKEN_TTL : '24h';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 3 'ENDUSER_TOKEN_TTL|SITENOVA_ENDUSER_TOKEN_TTL' backend
rg -n -C 3 'validationSchema|validate\s*:|ConfigModule' backend

Repository: rocket-admin/rocketadmin

Length of output: 7274


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect relevant usages and package metadata without running repository code.
printf '\n--- data-structure excerpt ---\n'
sed -n '1,120p' backend/src/microservices/sitenova-microservice/data-structures/sitenova-site.ds.ts

printf '\n--- auth service excerpt ---\n'
sed -n '1,140p' backend/src/microservices/sitenova-microservice/services/sitenova-enduser-auth.service.ts

printf '\n--- jwt dependency metadata ---\n'
python3 - <<'PY'
import json, pathlib
paths = [path for path in pathlib.Path('backend').rglob('package-lock.json') | list(pathlib.Path('.').rglob('package-lock.json'))]
for p in sorted(paths)[:10]:
    print(f'\n[{p}]')
    try:
        data=json.loads(p.read_text())
    except Exception as e:
        print(e)
        continue
    for key,node in (data.get('packages') or {}).items():
        if key.endswith('/jsonwebtoken') or key == 'jsonwebtoken':
            print(node.get('version'), node.get('resolved'))
PY

printf '\n--- docs/package references ---\n'
cat package.json 2>/dev/null | sed -n '1,160p' || true
cat backend/package.json 2>/dev/null | sed -n '1,160p' || true

printf '\n--- static verification of assigned value and usage ---\n'
python3 - <<'PY'
from pathlib import Path
dt=Path('backend/src/microservices/sitenova-microservice/data-structures/sitenova-site.ds.ts')
au=Path('backend/src/microservices/sitenova-microservice/services/sitenova-enduser-auth.service.ts')
for p in (dt, au):
    text=p.read_text(encoding='utf-8')
    print(p, len(text.splitlines()))
PY

printf '\n--- package-lock jsonwebtoken entries ---\n'
python3 - <<'PY'
import json, pathlib
for p in pathlib.Path('.').rglob('package-lock.json'):
    if '.npm' in str(p):
        continue
    data=json.loads(p.read_text())
    for key,node in (data.get('packages') or {}).items():
        if key == 'backend' or key.endswith('/jsonwebtoken') or key == 'jsonwebtoken':
            print(key, node.get('name'), node.get('version'), node.get('resolved'))
PY

Repository: rocket-admin/rocketadmin

Length of output: 7755


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n--- package-lock jsonwebtoken entries ---\n'
python3 - <<'PY'
import json
from pathlib import Path
for p in Path('.').rglob('package-lock.json'):
    if '.npm' in str(p):
        continue
    try:
        data=json.loads(p.read_text())
    except Exception as e:
        print(f'[{p}] parse error {e}')
        continue
    for key,node in (data.get('packages') or {}).items():
        pkg_name=node.get('name') if isinstance(node, dict) else None
        if key.endswith('/jsonwebtoken') or key == 'jsonwebtoken' or pkg_name == 'jsonwebtoken':
            print(key, pkg_name, node.get('version'), node.get('resolved'))
    print()
PY

printf '\n--- root package.json ---\n'
cat package.json 2>/dev/null || true

printf '\n--- backend package.json ---\n'
cat backend/package.json 2>/dev/null | sed -n '1,220p' || true

printf '\n--- config module references ---\n'
cat backend/src/shared/config/config.module.ts 2>/dev/null | sed -n '1,220p' || true

Repository: rocket-admin/rocketadmin

Length of output: 6331


🌐 Web query:

jsonwebtoken v9 expiresIn accepts number milliseconds seconds valid duration string

💡 Result:

In jsonwebtoken v9, the expiresIn option is interpreted differently depending on whether you provide a number or a string [1][2]. When you provide a number, it is interpreted as the count in seconds (e.g., 60 means 60 seconds) [1][3]. When you provide a string, it must be a valid time span string (e.g., "2 days", "10h", "7d") [1][2]. If the string does not specify a unit, it is interpreted as milliseconds by default (e.g., "120" is treated as "120ms") [1][3]. To avoid confusion when using strings, it is recommended to explicitly include the time units (such as "s", "m", "h", "d") [1].

Citations:


Validate ENDUSER_TOKEN_TTL at config load.

SITENOVA_ENDUSER_TOKEN_TTL accepts any non-empty string and passes it to jwt.sign({ expiresIn: ... }). A bare value such as 120 is read as milliseconds, and an invalid duration can make SignUser login or request token signing blow up. Validate the duration up front and fail startup instead of deferring the failure to JWT creation.

🤖 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
`@backend/src/microservices/sitenova-microservice/data-structures/sitenova-site.ds.ts`
around lines 9 - 10, Validate ENDUSER_TOKEN_TTL when initializing
SITENOVA_ENDUSER_TOKEN_TTL, accepting only durations supported by jwt.sign and
rejecting bare numeric or invalid values. Fail configuration loading immediately
with a clear error instead of allowing invalid TTLs to reach token-signing code.

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