Commit c4799261 authored by Erik Moravec's avatar Erik Moravec
Browse files

feat: league manager role added

parent 71b8ad76
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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");
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -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();
+1 −2
Original line number Diff line number Diff line
@@ -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))