@Override public void configure(HttpSecurity http) throws Exception { String path = this.console.getPath(); String antPattern = (path.endsWith("/") ? path + "**" : path + "/**"); HttpSecurity h2Console = http.antMatcher(antPattern); h2Console.csrf().disable(); h2Console.httpBasic(); h2Console.headers().frameOptions().sameOrigin(); String[] roles = this.security.getUser().getRole().toArray(new String[0]); SecurityAuthorizeMode mode = this.security.getBasic().getAuthorizeMode(); if (mode == null || mode == SecurityAuthorizeMode.ROLE) { http.authorizeRequests().anyRequest().hasAnyRole(roles); } else if (mode == SecurityAuthorizeMode.AUTHENTICATED) { http.authorizeRequests().anyRequest().authenticated(); } }
@Override public void configure(HttpSecurity http) throws Exception { String logoutSuccessUrl = buildUrl(casSecurityProperties.getServer().getBaseUrl(), casSecurityProperties.getServer().getPaths().getLogout()); http.logout().permitAll().logoutSuccessUrl(logoutSuccessUrl); SecurityAuthorizeMode mode = casSecurityProperties.getAuthorizeMode(); if (mode == SecurityAuthorizeMode.ROLE) { List<String> roles = securityProperties.getUser().getRole(); http.authorizeRequests().anyRequest().hasAnyRole(roles.toArray(new String[roles.size()])); } else if (mode == SecurityAuthorizeMode.AUTHENTICATED) { http.authorizeRequests().anyRequest().authenticated(); } }