Skip to content

Instantly share code, notes, and snippets.

@rjozefowicz
Last active June 7, 2024 21:22
Show Gist options
  • Save rjozefowicz/a5aeaed87d9934cc2af18cfa8bc17aa3 to your computer and use it in GitHub Desktop.
Save rjozefowicz/a5aeaed87d9934cc2af18cfa8bc17aa3 to your computer and use it in GitHub Desktop.
spring security workshop 09.06.2024
@rjozefowicz
Copy link
Author

rjozefowicz commented Nov 4, 2023

Extra do APIKey:

  • rozszerz APIKey o rolę - pojedynczą (ADMIN, USER)
  • zmapuj rolę na GrantedAuthority która trafia do UsernamePasswordAuthenticationToken
  • w SecurityFIlterChain dodaj POST /organizations tylko dla ADMIN

Ściągawka:
.requestMatchers("/organizations/{organizationId}/**").access(new WebExpressionAuthorizationManager("hasRole('ROOT') or @securityService.canAccessOrganization(#organizationId)”))
albo
requestMatchers(.....).hasAuthority()

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