Checks stored permission strings against the application's resources.
Permission strings live in your roles table, seeds or migrations — the compiler
never sees them. This task runs AshGrant.PermissionValidation.check_all/2
over a file of them, so a pipeline can refuse a release whose code no longer
matches the strings it will meet (a renamed action, scope or field group, or a
plain typo).
Usage
mix ash_grant.check_permissions FILE [options]FILE is either:
- a
.jsonfile holding an array of permission strings, or an object whose values are arrays of them ({"editor": ["post:*:read:always"]}) — the keys are shown next to each finding; or - any other file, read as one permission per line. Blank lines and lines
starting with
#are skipped.
Pass - to read a newline list from standard input:
psql -At -c "select unnest(permissions) from roles" | mix ash_grant.check_permissions -Options
--otp-app- Check against the resources in this application's:ash_domains. Without it, every AshGrant resource in the started applications':ash_domainsis used.--format-text(default) orjson.
Exit codes
- 0 - No issue of severity
:error. Warnings are printed but do not fail. - 1 - At least one
:error. - 2 - Usage error (missing file, unreadable input, invalid option).
Summary
Functions
Pure entry point used by both run/1 and the test suite.
Functions
Pure entry point used by both run/1 and the test suite.
Returns {:ok | :error, output_string, exit_code}. Accepts a :resources
option in check_opts so tests can pin the resources without an OTP app.