feat: implement permissions management with WASM backend and in-memory support#6
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a
PermissionsAPI for plugins to check the current caller's effective permissions, and hardensplugintest's in-memory DB WHERE-clause matching to support multi-conditionANDandIS [NOT] NULLpredicates.New Permissions API:
PermissionBackendinterface andPermissionstype tobackends.go, exposed viaContext.Permissions().Check(permission)so route handlers can enforce authorization finer-grained than the single all-or-nothing scope declared on the route's manifest entry — e.g. "is the caller the record's owner OR do they holdtime_logging.manage_all".newContext/NewContextForTest(context.go,testing.go) and the WASM dispatcher (dispatch.go).wasmPermissionBackendinwasm_backends.go, backed by a newpaca.permission_checkhost import declared inwasm_imports.go.stubPermissionBackendinnative_backends.gothat always denies, so non-WASM builds compile and fail closed.FakePermissionstoplugintest/backends.go— an in-memoryPermissionBackendwithGrant/Revokemethods, denied by default — and exposed it asContext.Permissionsinplugintest/plugintest.go.In-memory DB WHERE-clause fixes:
parseSimpleSelect/parseSimpleWhere(single-condition only) with a sharedparseTableAndConditions, and renamedrowMatchesConditionstomatchesConditions, so SELECT and DELETE now evaluate the full WHERE clause instead of silently checking only the firstAND-ed condition.IS NULL/IS NOT NULLconditions, matching patterns likedeleted_at IS NULLcommonly used for soft-delete checks.plugintest/backends_test.gocovering multi-condition SELECT/DELETE andIS [NOT] NULL, including a regression test guarding against a WHERE evaluator that only checks the first condition.Also includes minor
//nolintcomment-placement fixes innative_protocol.goandplugin.gofrom gofmt.