Skip to content

feat(iam): admit protected routes with route-local Permission guards - #65

Merged
nivek-ph merged 8 commits into
mainfrom
feat/request-access-route-admission
Sep 3, 2026
Merged

feat(iam): admit protected routes with route-local Permission guards#65
nivek-ph merged 8 commits into
mainfrom
feat/request-access-route-admission

Conversation

@nivek-ph

@nivek-ph nivek-ph commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Split Request Access into router-level Authentication (token/session/user status) and a route-local Permission guard that makes one Authorization decision per protected management method.
  • Move HTTP topology fully onto Axum route registration: each management handler declares permission(code, MethodRouter). The Access Catalog no longer stores or exposes HTTP method/path bindings, and Router construction no longer looks them up.
  • Drop sys_menu_apis (migrations/0003_drop_menu_api_bindings.sql). Self-Service stays authenticated but unguarded. Remove the unused CatalogError → AppError mapping so catalog tree errors stay on init (IamInitError) and Role Access input (INVALID_ROLE_ACCESS).

Test plan

  • Existing databases apply 0003_drop_menu_api_bindings.sql (DROP TABLE sys_menu_apis)
  • Unauthenticated protected route → 401 LOGIN_REQUIRED; authenticated 405 stays wrapped; unknown path stays 404
  • Zero-role user can use Self-Service (GET /api/users/me) and is denied on management routes (403 PERMISSION_DENIED)
  • Concrete Permission allows the matching method; a different management action on the same resource stays denied
  • GET/HEAD share the same guard; denial audit records the actual request path
  • Dropping sys_audit_events still returns 403 and does not override the denial
  • Missing Permission-guard context fails closed (500 INTERNAL_SERVER_ERROR, handler not called)
  • Admin Console menus page no longer shows API bindings
  • cargo fmt --all -- --check
  • cargo test --workspace
  • cd apps/desktop && pnpm test

- Clarified the role of Router-level Authentication and Permission guards in access management.
- Removed references to deprecated API bindings in the MenuRecord interface.
- Enhanced error handling documentation to reflect changes in authentication and authorization processes.
- Updated frontend tests to align with the new structure and removed obsolete API binding checks.
- Cleaned up Cargo.toml and Cargo.lock by removing unused dependencies.
- Eliminated the implementation of From trait for iam::access::CatalogError to AppError, streamlining error handling in the mappings module.
@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
axum-admin Ignored Ignored Sep 3, 2026 3:22pm UTC
axum-admin-web Ignored Ignored Sep 3, 2026 3:22pm UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 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-09-03T15:18:06.753971Z 58eab3f Manual request
ℹ️ 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.

@nivek-ph

nivek-ph commented Sep 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: c49d92029b

ℹ️ 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".

@nivek-ph

nivek-ph commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 39d0d69293

ℹ️ 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".

next.policy.set_watcher(Box::new(watcher));
}
*self.policy.write().await = next;
*self.snapshot.write().await = next;

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 Prevent reloads from overwriting newer status changes

When a periodic or Redis-triggered reload reads User/Role status, then a concurrent set_user_status or set_role_status updates the active snapshot before this assignment, the older candidate replaces that newer state here. Disabling a User or Role can therefore leave its previous permissions active until the next periodic reload (30 seconds in the server), because self-originated notifications are ignored. Serialize local status mutations with reloads or reject stale candidates before swapping them.

AGENTS.md reference: AGENTS.md:L50-L54

Useful? React with 👍 / 👎.

.await?;
snapshot.users.remove(&user_id);
drop(snapshot);
self.notify_reload();

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 Notify peers after deleting the User row

In a multi-process deployment, this is the last reload notification emitted for account deletion, but Accounts::delete does not delete the authoritative sys_users row until after remove_user returns. A peer that handles this notification in that interval reloads the User as enabled, and no later notification corrects it, so an existing token remains admitted to Self-Service routes until periodic repair. Emit a final notification after the User row has been deleted.

AGENTS.md reference: AGENTS.md:L50-L54

Useful? React with 👍 / 👎.

…oad notifications

- Added reload lock handling in user and role removal methods to ensure consistency during updates.
- Updated the Accounts service to notify reload after user deletion.
- Introduced a public notify_reload method in the Authorization service for better encapsulation of reload logic.
- Improved documentation in the IAM architecture to clarify the reload mechanism and its impact on policy freshness.
@nivek-ph

nivek-ph commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

- Updated the user deletion method to return an error if the specified user ID does not exist in the database.
- Enhanced error handling to improve robustness in the Accounts service.
@nivek-ph

nivek-ph commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

…pdates

- Introduced tests to verify that the `reload` and `replace_user_roles` functions respect the `mutation_lock`, ensuring that concurrent updates do not overwrite changes.
- Added checks to confirm that role assignments and permission mutations remain visible in the active snapshot after the lock is released.
- Removed outdated tests related to concurrent reloads that were previously in the `authorization.rs` file.
@nivek-ph

nivek-ph commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 58eab3fd35

ℹ️ 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 thread crates/iam/src/authorization/engine.rs
- Updated the EnforcementEngine to clarify that network I/O operations occur outside the mutation critical section, ensuring that only snapshot/watcher installations are serialized.
- Added a comment to enhance code readability regarding the mutation lock's role in the context of Redis interactions.
@nivek-ph
nivek-ph merged commit 141aa20 into main Sep 3, 2026
8 checks passed
@nivek-ph
nivek-ph deleted the feat/request-access-route-admission branch September 3, 2026 15:22
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.

1 participant