fix(policy): throw on unknown action, identity errors, and string grants - #3415
Merged
Conversation
Unknown publish, a throwing DI currentUser, a throwing authenticator, and policy methods that return yes/true must fail the Authorization filter on develop. Reserved init/scope stay Wheels.NotAuthorized. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Peter Amiri <peter@alurium.com>
authorize() and can() throw Wheels.Policy.UnknownAction when the method is missing. Reserved init and scope still deny as Wheels.NotAuthorized. $currentUserForPolicy() lets a throwing currentUser or authenticator propagate. Only boolean true grants. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Peter Amiri <peter@alurium.com>
Production $notAuthorized() still writes Forbidden and abort. The Authorization filter sets request.\$wheelsIsolateAbort so that path throws Wheels.NotAuthorized instead of aborting the TestBox request. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Peter Amiri <peter@alurium.com>
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.
Why
Peter flipped the three Policy holds that #3414 left unflipped. Unknown policy actions were a silent deny (
can()returned false,authorize()threwWheels.NotAuthorizedas if the policy had spoken). A throwing DIcurrentUserfell through to the authenticator user. A throwing authenticator became guest"".authorize()andcan()treated the CFML strings"yes"and"true"as a grant.This PR flips S1, S3, and S4 only. Desk IDs stay S1/S3/S4. S2 and S5–S9 already landed on develop in #3414.
Scope
vendor/wheels/controller/authorization.cfc$invokePolicyAction()throwsWheels.Policy.UnknownActionwhen the method is missinginitandscopestill deny asWheels.NotAuthorized(S9)$policyGranted()grants only whenSerializeJSON(allowed) == "true"$currentUserForPolicy()no longer hascatch(any)failoverabortstays. The filter setsrequest.$wheelsIsolateAbortso that path throws instead of aborting the TestBox requestvendor/wheels/tests/specs/Authorization/AuthorizationSpec.cfcCurrentUserThrowingStub.cfc,ThrowingCurrentUserStrategy.cfc, plusyesGrant/trueGrant/boolGrantonPostPolicy.cfcchangelog.d/policy-hardener-s1-s3-s4.changed.mdand.security.mdCLI stays out.
vendor/wheels/Policy.cfcis unchanged. S2/S5–S9 specs stay as they are except the S8 abort isolate.Tradeoffs
Wheels.Policy.UnknownActionis a programmer error (HTTP 500 via the existingWheels.*mapping), not a deny (403). That is the typo-fails-loud point. A wrappedWheels.Policy.IdentityResolutionFailedwould hide the original boom type, so identity failures propagate as-is.SerializeJSON(allowed) == "true"is the grant check. Booleantrueserializes to the JSON boolean. The strings"yes"and"true"serialize quoted and deny. Numeric1serializes as1and also denies.Blast Radius
can("publish", post)now throws instead of returning false. Views that usedcan()to hide a button for a missing method will 500 until the method exists or the call is fixed. That is the S1 flip.Apps that registered a broken
currentUserDI service and relied on authenticator failover will now see the resolver exception. Guest""when nothing is registered is unchanged (S7).Policy methods declared
booleanthatreturn "yes"still grant if the engine coerces the return at the method boundary. S4 is about the valueauthorize()/can()receive.Desk S1–S9
authorize(action="publish")andcan("publish")throwWheels.Policy.UnknownAction. Reservedinit/scopestayWheels.NotAuthorized.whereIn.currentUserdoes not become the authenticator user (Wheels.Policy.CurrentUserBoom). Throwing authenticator does not become guest""(Wheels.Policy.AuthenticatorBoom).authorize()andcan()deny"yes"and"true". Booleantruestill grants.currentUserand authenticator identity."".$wheelsIsolateAbortand restores 200.init/scopeareWheels.NotAuthorized.Verification
JSON from the same filter (
directory=wheels.tests.specs.Authorization):HEAD
1ee8f57bb24b338110dc1193d1c0a975c27ada02Base
06acc07d82cbacbf7a8a43c596fc9b838878568e(develop after #3414).Wheels CLI 4.0.6. Lucee 7.0.0.395. sqlite.
No closer keywords. Do not merge.