Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@paulineribeyre
Copy link
Contributor

@paulineribeyre paulineribeyre commented Mar 4, 2024

Jira Tickets: PXP-11248 and PXP-11258

Changes from #159 + unit tests + fix handleAuthMappingPOST to work when no body is provided + minor refactoring

New Features

  • POST /auth/mapping supports parsing username and client ID from a token instead of from the request body.
  • POST /auth/mapping supports tokens produced from a "client_credentials" OIDC flow.

Breaking Changes

Bug Fixes

Improvements

Dependency updates

Deployment changes

}
msg := fmt.Sprintf("Expected response to be these auth mappings from anonymous and logged-in groups: %v", expectedMappings)
for resource, actions := range result {
assert.Contains(t, expectedMappings, resource, msg)

Choose a reason for hiding this comment

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

Just for my understanding - if this "hulkhogan12" has auth mappings other than loggedIn or anonymous, this assert.Contains will fail. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes πŸ‘


router.Handle("/auth/mapping", http.HandlerFunc(server.handleAuthMappingGET)).Methods("GET")
router.Handle("/auth/mapping", http.HandlerFunc(server.parseJSON(server.handleAuthMappingPOST))).Methods("POST")
router.Handle("/auth/mapping", http.HandlerFunc(server.handleAuthMappingPOST)).Methods("POST")

Choose a reason for hiding this comment

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

Is the main purpose of this change to bypass the baseHandler function call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The endpoint used to only accept input in the request body. Now that we allow passing a token and no body, we don't need parseJSON (it errors when there is no body). So i refactored the "body parsing" logic out of parseJSON so i could call it manually in handleAuthMappingPOST(), only when we need it. When only a token is passed, we don't call it

Choose a reason for hiding this comment

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

that makes sense. so if this expression is satisfied
authHeader := r.Header.Get("Authorization"); authHeader != ""
then we don't parse the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants