refactor(middleware): cut checkAuthorization cyclomatic complexity#117
Merged
Conversation
… complexity The fail-closed sub guard pushed checkAuthorization to gocyclo 17 (> 16). Extract the subject-derivation branch (M2M role vs normal-user identity, with the owner/sub guards) into deriveSubject, bringing checkAuthorization back to 15. No behavior change. X-Lerian-Ref: 0x1
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe middleware now derives authorization subjects from JWT claims in a helper and uses that helper during authorization checks. The missing- ChangesAuthorization subject derivation
Possibly related PRs
✨ Finishing Touches✨ Simplify code
Comment |
…ckend TestCheckAuthorization_MissingSubClaim asserted the 401 result but not the fail-closed guarantee. Replace the permissive mock with a handler that fails the test if hit, proving a missing-sub normal-user token is rejected before any request to the auth service. X-Lerian-Ref: 0x1
|
🎉 This PR is included in version 2.9.0-beta.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
7 tasks
|
🎉 This PR is included in version 2.9.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Pull Request Type
Summary
CI lint (gocyclo via reviewdog) flagged
(*AuthClient).checkAuthorizationat cyclomatic complexity 17 (> 16) after the fail-closedsubguard landed in #116.This extracts the subject-derivation branch (M2M editor-role vs normal-user identity, including the owner/sub fail-closed guards) into a new helper
deriveSubject, bringingcheckAuthorizationback to 15.Why a separate PR
#116 was already merged into
develop(andv2.9.0-beta.2was cut) before the lint fix was ready, so it lands as a small follow-up.Guarantees
gocyclo -over 16→ clean.MissingSubClaim/MissingOwnerClaim/ empty-product tests still pass against the extracted helper).Notes
Should land in
developbefore promotingv2.9.0to stable (PR #115), so the release line is lint-clean.