Java 类org.springframework.boot.autoconfigure.security.SecurityAuthorizeMode 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:H2ConsoleAutoConfiguration.java   
@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();
    }
}
项目:spring-boot-concourse    文件:H2ConsoleAutoConfiguration.java   
@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();
    }
}
项目:contestparser    文件:H2ConsoleAutoConfiguration.java   
@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();
    }
}
项目:cas-security-spring-boot-starter    文件:CasSecurityAutoConfiguration.java   
@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();
    }
}