mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 02:27:57 +00:00
DataPermission, PermissionAction, Permission, GetPermissionFromContext, IsValidDataScope, PermissionKey and the five DataScope* constants now forward to go-admin-core's sdk/contract/actions, which carries the already-fixed logic from feat/006-security-prereq (PRD 006 F14/H1-H3). create.go/delete.go/index.go/update.go/view.go - the five generic CRUD actions - are untouched: they call Permission and GetPermissionFromContext by the same names, which now resolve to forwards with identical behaviour, and stay in this package rather than moving to core (PRD 006 F3: core's exports are a permanent promise every fork inherits, and CRUD shape is this framework's most volatile surface). PermissionKey is declared as `const PermissionKey = contractactions.PermissionKey`, a direct reference rather than a restated literal, per PRD 006's hard constraint 4: PermissionAction sets this gin context key and GetPermissionFromContext reads it back, and an independently declared copy could silently drift from core's if one were ever edited without the other. permission_test.go replaces the detailed data-permission regression suite - which now lives in core, next to the logic itself - with a test of this package's own wiring: that PermissionAction and both of this package's own read paths (GetPermissionFromContext, and c.Get(actions.PermissionKey) directly) still meet on the same key. Counterproof performed and reverted (not part of this commit): with PermissionKey redeclared here as the literal "dataPermission" and core's copy changed to a different value, TestPermissionKeyMatches- WhatPermissionActionSets went red while GetPermissionFromContext's own round-trip stayed green - confirming the exported constant, not the GetPermissionFromContext wrapper, is what an independent literal would put at risk. PRD 006 F3/F5. Claude-Session: https://claude.ai/code/session_01HPTAw8b8tAdFNFn8rKdPYx
14 lines
727 B
Go
14 lines
727 B
Go
package actions
|
|
|
|
import contractactions "github.com/go-admin-team/go-admin-core/v2/sdk/contract/actions"
|
|
|
|
// PermissionKey is a direct reference to go-admin-core's sdk/contract/actions
|
|
// constant, not a restated literal - see that package's PermissionKey doc
|
|
// comment. PRD 006's hard constraint 4 requires this form for exactly this
|
|
// symbol: PermissionAction (below) sets the gin context key it owns, and
|
|
// GetPermissionFromContext reads it back; an independently declared literal
|
|
// here would let the two silently drift apart if core's copy ever changed
|
|
// without this one following. common/actions/shim_test.go carries the
|
|
// regression test for that failure mode.
|
|
const PermissionKey = contractactions.PermissionKey
|