Skip to content

DRAFT refactor(vault): [OCISDEV-1516] move the vault checks into a separate interceptor - #809

Open
2403905 wants to merge 4 commits into
mainfrom
OCISDEV-1516/vault-refactor
Open

2403905 wants to merge 4 commits into
mainfrom
OCISDEV-1516/vault-refactor

Conversation

@2403905

@2403905 2403905 commented Nov 12, 2026

Copy link
Copy Markdown

Description

This pull request answers the review comments of jvillafanez on #787.

Dependency: this branch starts from the branch of #787. Until #787 is merged, this pull request also shows the 3 commits of #787. Review only the last commit, refactor(vault): move the vault checks into a separate interceptor. Merge #787 first.

Changes

  1. New package pkg/vault
    • IsVaultStorage, IsVaultSpace, PermissionGranted, and HasVaultMode hold the one VaultMode check. Before this change, the auth interceptor, the gateway, and oCIS had their own copies.
    • The Checker type can cache the definitive answers. Each Checker has its own cache. FilterUsers checks a list of users in parallel, with a limit.
    • The package globals and the sync.Once are removed. Before this change, all auth interceptors in one process used the cache settings of the first interceptor.
  2. New interceptor vault (internal/grpc/interceptors/vault)
    • The interceptor runs after the auth interceptor. It denies users without MFA or without the VaultMode permission. Service accounts are not checked.
    • Options: mfa_required, vault_mode_required, vault_mode_cache_size, vault_mode_cache_seconds, priority.
    • mfa_required replaces the option mfa_enabled of the auth interceptor. No release contains mfa_enabled.
    • The auth interceptor now only authenticates.
  3. Gateway: granteeMayAccessVault uses pkg/vault.
  4. Loader test: rgrpc ignores a configured interceptor that is not registered. The new test fails when the loader does not register the vault interceptor.

Not in this pull request

  • The globals userGroupsCache and scopeExpansionCache of the auth interceptor have the same pattern. They affect all services, so they need a separate ticket.

Related

Tests

  • go test -race ./pkg/vault/
  • go test ./internal/grpc/interceptors/... ./internal/grpc/services/gateway/ ./pkg/rgrpc/...
  • golangci-lint run for the changed packages: no findings.

🤖 Generated with Claude Code

2403905 and others added 4 commits November 10, 2026 12:33
The gateway now accepts a group as the grantee of a vault share or of a
vault space membership. The gateway does not check the VaultMode
permission for a group, because role assignments belong to single
accounts and group membership can change. The ocis notification services
filter the group members by VaultMode instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t storage

Add the auth interceptor option vault_mode_required. When the option is
on, the interceptor denies each request from a user who does not hold
the VaultMode permission. Service accounts are not checked. The
interceptor caches definitive answers for each user for 30 seconds. An
error during the check denies the request.

The vault storage provider uses this option. A group member without the
VaultMode permission then cannot open a vault resource that is shared
with the group.

NewStream now resolves the gateway address in the same way as NewUnary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… event

The events middleware read the granteegroupid value of a removed share
into the user ID field. Thus the ShareRemoved event of a group share
contained the group ID as a user ID, and GranteeGroupID was empty. The
notification services then sent the "Resource unshared" notification
to no member of the group.

Read the value into the group ID field. Add a test for a group grantee
and for a user grantee.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Roman Perekhod <2403905@gmail.com>
… interceptor

The auth interceptor checked MFA and the VaultMode permission. The
interceptor kept the VaultMode cache and the gateway client in package
globals. In one process, all auth interceptors used the cache settings
of the first interceptor.

Add the package pkg/vault. It holds the VaultMode check and a Checker
type. Each Checker has its own cache. The gateway and the new
interceptor use this package. Other services, for example oCIS, can
use it too.

Add the interceptor vault. It runs after the auth interceptor and
denies users without MFA or without the VaultMode permission. The
option mfa_required replaces the option mfa_enabled of the auth
interceptor. The auth interceptor now only authenticates.

Add a test that fails when the loader does not register the vault
interceptor. rgrpc ignores a configured interceptor that is not
registered, so a missing import would leave the vault unprotected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Roman Perekhod <2403905@gmail.com>
@2403905
2403905 requested a review from a team as a code owner November 12, 2026 08:44
@kw-security

kw-security commented Nov 12, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@2403905 2403905 changed the title refactor(vault): [OCISDEV-1516] move the vault checks into a separate interceptor DRAFT refactor(vault): [OCISDEV-1516] move the vault checks into a separate interceptor Nov 16, 2026
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