Skip to content

Commit

Permalink
NOJIRA: Pac4J libs update
Browse files Browse the repository at this point in the history
Fixes for login with no valid role causing error loop and filter chain checks for static assets
  • Loading branch information
chasegawa committed Feb 2, 2024
1 parent e9cd237 commit 768d2d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ public InMemoryUserDetailsManager userDetailsManager() {
@Bean
@Profile("!no-auth")
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
return (web) -> web.ignoring().requestMatchers(new AntPathRequestMatcher("/unsecured/**/*"),
new AntPathRequestMatcher("/entities/**/*"),
new AntPathRequestMatcher("/favicon.ico"),
new AntPathRequestMatcher("/assets/**/*.png"),
new AntPathRequestMatcher("/static/**/*"),
new AntPathRequestMatcher("/**/*.css")).and().httpFirewall(allowUrlEncodedSlashHttpFirewall());
}

private HttpFirewall allowUrlEncodedSlashHttpFirewall() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public WebSecurityCustomizer webSecurityCustomizer() {
firewall.setAllowUrlEncodedDoubleSlash(true);
firewall.setAllowSemicolon(true);

return (web) -> web.httpFirewall(firewall);
return (web) -> web.ignoring().requestMatchers(new AntPathRequestMatcher("/unsecured/**/*"),
new AntPathRequestMatcher("/entities/**/*"),
new AntPathRequestMatcher("/favicon.ico"),
new AntPathRequestMatcher("/assets/**/*.png"),
new AntPathRequestMatcher("/static/**/*"),
new AntPathRequestMatcher("/**/*.css")).and().httpFirewall(firewall);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public Optional<Credentials> validate(CallContext ctx, Credentials credentials)
Optional<Credentials> validatedCreds = super.validate(ctx, credentials);
validatedCreds.ifPresent(creds -> {
CommonProfile profile = (CommonProfile) creds.getUserProfile();
if (profile == null) {
return;
}
profile.setRoles(userService.getUserRoles(profile.getUsername()));
creds.setUserProfile(profile);
userService.updateLoginRecord(profile.getUsername());
Expand Down

0 comments on commit 768d2d1

Please sign in to comment.