Skip to content

Fix authz plugin: add RWMutex to defaultRegistry#2

Merged
intel352 merged 7 commits intomainfrom
fix/ws08-authz-mutex
Feb 26, 2026
Merged

Fix authz plugin: add RWMutex to defaultRegistry#2
intel352 merged 7 commits intomainfrom
fix/ws08-authz-mutex

Conversation

@intel352
Copy link
Contributor

Summary

  • Add sync.RWMutex to defaultRegistry in step_authz_check.go to protect concurrent reads and writes
  • set() acquires a write lock when registering modules; GetEnforcer() acquires a read lock when looking up modules
  • Fixes a race condition when the authz step module is registered and looked up concurrently

Test plan

  • go build ./... passes
  • go test ./... passes (ok github.com/GoCodeAlone/workflow-plugin-authz/internal)
  • Running with -race flag would no longer trigger data race detector on registry access

🤖 Generated with Claude Code

intel352 and others added 4 commits February 26, 2026 16:22
…ccess

The defaultRegistry map was unprotected against concurrent reads and writes.
This adds a sync.RWMutex to protect:
- set(): Write lock when registering modules
- GetEnforcer(): Read lock when looking up modules

Fixes race condition in authz step module registration and lookups.
…e conflict

workflow v0.2.2 pulled in gorm.io/plugin/dbresolver@v1.3.0 which references
a removed field (PreparedSQL) in the current gorm version, causing CI build
failures. Upgrading to v0.2.18 removes this transitive dependency conflict.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
….3.0

gorm.io/plugin/dbresolver@v1.3.0 references PreparedSQL field that was
removed from gorm.PreparedStmtDB, causing go vet and build to fail.
CI's go mod tidy pulls this version transitively via casbin/gorm-adapter/v3.
Replace it with v1.5.3 which is compatible with current gorm.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…endency

casbin/casbin/v2 v2.104.0 caused CI's go mod tidy to pull in
casbin/gorm-adapter/v3 v3.24.0, which depends on:
- gorm.io/plugin/dbresolver@v1.3.0 (uses removed PreparedSQL field → build fail)
- glebarez/sqlite (duplicate "sqlite" driver registration → test panic)

casbin v2.135.0 does not trigger the gorm-adapter fetch. Removes the
replace directive for dbresolver since it's no longer needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@intel352 intel352 force-pushed the fix/ws08-authz-mutex branch from 3a90bdd to 9529bce Compare February 26, 2026 21:25
intel352 and others added 3 commits February 26, 2026 16:28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e driver registration

The gorm.io/driver/sqlite package and modernc.org/sqlite both register
the "sqlite" database/sql driver, causing a panic in tests with -race.
Custom sqliteDialector uses modernc.org/sqlite directly via database/sql.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add internal/gorm_adapter.go: minimal casbin persist.Adapter using gorm,
  replacing casbin/gorm-adapter/v3 to eliminate glebarez/sqlite dependency
- Remove now-unnecessary replace directive for gorm.io/plugin/dbresolver
  (gorm-adapter is fully removed, so dbresolver is no longer in the graph)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@intel352 intel352 merged commit 39d37ce into main Feb 26, 2026
9 checks passed
@intel352 intel352 deleted the fix/ws08-authz-mutex branch February 26, 2026 21:42
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