Skip to content

Fix logic auth role test#45

Merged
moutonjeremy merged 9 commits intomainfrom
fix-logic-auth-role-test
Mar 13, 2026
Merged

Fix logic auth role test#45
moutonjeremy merged 9 commits intomainfrom
fix-logic-auth-role-test

Conversation

@moutonjeremy
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings March 13, 2026 18:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts how OpenAPIOptions.RequiredRoles is enforced during authorization and updates the associated tests to match the new behavior.

Changes:

  • Change checkRequiredRoles from “must have all roles” (AND) to “must have at least one role” (OR).
  • Update TestRequiredRoles multi-role route and subtests to reflect OR semantics.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
auth.go Updates required-role authorization logic to OR semantics and changes the 403 error message.
auth_test.go Updates route/test expectations for multi-role access using OR semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

auth.go Outdated
Comment on lines 219 to 221
// checkRequiredRoles checks that the authenticated user has at least one of the required roles (OR semantics).
// Called inside validateAuthorization after auth context is established, before resource access checks.
func checkRequiredRoles(authCtx *AuthContext, authService AuthorizationService, requiredRoles []string) error {
auth.go Outdated
}
}
return nil
return &AuthError{StatusCode: 403, Message: fmt.Sprintf("none of the required roles found: %v", requiredRoles)}
@@ -681,8 +681,8 @@ func TestRequiredRoles(t *testing.T) {
}
})

…amples for improved clarity and completeness. Add detailed configuration options and examples for authentication and authorization. Revise HTTP methods section to include PATCH and HEAD. Improve documentation on validation, error handling, and role-based access control.
@moutonjeremy moutonjeremy merged commit a1a321f into main Mar 13, 2026
4 checks passed
@moutonjeremy moutonjeremy deleted the fix-logic-auth-role-test branch March 13, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants