Skip to content

fix(auth): enforce middleware on merged GraphQL and federation routes - #336

Merged
hyperpolymath merged 4 commits into
mainfrom
fix/auth-router-coverage
Oct 31, 2026
Merged

hyperpolymath merged 4 commits into
mainfrom
fix/auth-router-coverage

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

P0 security boundary

build_router applied authentication/RBAC middleware to the REST router before merging separately constructed GraphQL and federation routers. In Axum, a layer on an existing Router does not automatically wrap routes merged afterward. The GraphQL endpoint includes create and delete octad mutations.

Repair

  • Move auth_middleware to the outermost combined router after merging GraphQL and federation.
  • Add an authenticated-mode HTTP regression test checking unauthenticated GraphQL mutation and federation peer query return 401, authenticated writer GraphQL requests reach the handler, and public health remains reachable.

Scope and unresolved problems

  • This protects routes only when AuthConfig.enabled = true. The application currently constructs AuthState::default() (authentication disabled), and secure deployment configuration is an independent P0.
  • The gRPC port runs separately and is not protected by this middleware; gRPC interceptors/mTLS are required before exposure.
  • REST method-based RBAC treats POST /graphql as Write even for read-only GraphQL operations. The safe default is restrictive; a follow-up needs operation-aware permission checks.
  • Federation registration still has its own PSK checks; this change adds the outer API boundary when enabled.

No data migration or destructive operation. Draft pending CI and security review.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4e2c43e and d157627.

Files selected for processing: 1
  • rust-core/verisim-api/src/lib.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T22:20:01.315224Z d157627 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b756cab8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +860 to +863
.layer(axum_middleware::from_fn_with_state(
auth_state,
auth::auth_middleware,
))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve PSK-only access for federation peers

When AuthConfig.enabled is true, this outer layer rejects legitimate federation protocol requests before their handlers can validate federation credentials: heartbeat accepts the documented X-Federation-PSK header, and registration accepts its PSK in the request body, whereas auth_middleware recognizes only X-API-Key or Bearer credentials. Consequently, peers following the existing federation contract now receive 401 responses unless they are also provisioned with an unrelated general API credential; exempt the PSK-authenticated peer routes or integrate federation identities into this authentication boundary.

Useful? React with 👍 / 👎.

Comment on lines +860 to +863
.layer(axum_middleware::from_fn_with_state(
auth_state,
auth::auth_middleware,
))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Classify federated queries as execute operations

When authentication is enabled, a Reader credential can no longer issue the read-only POST /federation/query operation: the newly applied middleware sends this path through required_permission, but is_execute_path does not include /federation/query, so the POST fallback requires Write and returns 403 even though the built-in reader role explicitly has Execute. Add this endpoint to the execute-path classification so read-only clients retain query access.

Useful? React with 👍 / 👎.

Comment on lines +860 to +863
.layer(axum_middleware::from_fn_with_state(
auth_state,
auth::auth_middleware,
))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Enforce admin permission inside GraphQL mutations

When authentication is enabled, any Writer can submit the GraphQL updatePlannerConfig mutation because this middleware authorizes only the envelope POST /graphql, which maps to Write. The equivalent REST operation, PUT /planner/config, is explicitly classified as Admin, so routing GraphQL solely through method-based RBAC creates a role bypass for the same configuration change. Inspect the GraphQL operation or enforce permissions in the resolver before allowing this admin mutation.

Useful? React with 👍 / 👎.

@sonarqubecloud

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1576270e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +860 to +863
.layer(axum_middleware::from_fn_with_state(
auth_state,
auth::auth_middleware,
))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require admin permission for peer deregistration

When authentication is enabled, any Writer credential can now POST /federation/deregister/{store_id} because the outer middleware classifies this unlisted POST route as Write; the handler then removes the peer without requiring its federation PSK. This lets an ordinary data writer disrupt federation membership, so classify peer deregistration as Admin or enforce an equivalent permission in the handler.

Useful? React with 👍 / 👎.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) October 30, 2026 15:32
hyperpolymath added a commit that referenced this pull request Oct 31, 2026
…tions and v1 consumer contract (#337)

Independent code-grounded reconnaissance as of main
`5876bc67e8962e3b276fb0161664e0b3a420a64c`.

Adds three review documents:
- `docs/reviews/2026-10-29-verisimdb-as-built-recon.adoc` —
source-derived architecture, conceptual ER, eight-modality/persistence
matrix, actual lifecycle, P0/P1/P2 discrepancy register, tests and
formal proof obligations, independent
Mathesis/QuandleDB/JanusKey/Marches reuse, prioritized engineering
programme.
- `docs/consumer-interface-contract-v1-observed.adoc` — actual
flatten-vs-nested HTTP ABI, operations, HTTP statuses,
feature/configuration guarantees and explicit non-guarantees.
- `docs/reviews/2026-10-29-hypatia-verified-handover.adoc` — only
verified downstream integration facts.

No rewrite of the Octad schema; accepted generic term **modality
profile** distinguished from **modality set** and **consonance
subject**. References separate code fixes #333, #334, #335, #336. Makes
no soundness claims beyond observed source/test status. No data
mutation.
@hyperpolymath
hyperpolymath merged commit dd82709 into main Oct 31, 2026
21 of 22 checks passed
@hyperpolymath
hyperpolymath deleted the fix/auth-router-coverage branch October 31, 2026 22:40
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