Skip to content
Snippets Groups Projects
Commit c4799261 authored by Erik Moravec's avatar Erik Moravec
Browse files

feat: league manager role added

parent 71b8ad76
No related branches found
No related tags found
No related merge requests found
......@@ -85,5 +85,6 @@ public class DataLoader implements ApplicationRunner {
userAuth.createTeamManager("team_manager", "1234", team.intValue());
userAuth.createTeamManager("team_manager_slovan", "0000", team2.intValue());
userAuth.createLeagueManager("league_manager", "9876");
}
}
......@@ -67,8 +67,8 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
.withSubject(((String) auth.getPrincipal()))
.withExpiresAt(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
.sign(Algorithm.HMAC512(SECRET.getBytes()));
String body = auth.getPrincipal() + " " + token;
var role = auth.getAuthorities().stream().findFirst().orElseThrow().getAuthority();
String body = auth.getPrincipal() + " " + role + " " + token;
res.getWriter().write(body);
res.getWriter().flush();
......
......@@ -33,8 +33,7 @@ public class WebSecurity extends WebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll()
.antMatchers(HttpMethod.GET, "/pa165/api/public/**").permitAll()
.antMatchers("/pa165/api/manage/league/**").hasRole(Roles.LEAGUE_MANAGER.toString())
// .antMatchers("/pa165/api/manage/team/**").hasRole(Roles.TEAM_MANAGER.toString())
.antMatchers("/pa165/api/manage/team/**").permitAll()
.antMatchers("/pa165/api/manage/team/**").hasRole(Roles.TEAM_MANAGER.toString())
.anyRequest().authenticated()
.and()
.addFilter(new JWTAuthenticationFilter(userAuthFacade))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment