本文整理汇总了Java中org.springframework.security.web.util.matcher.AntPathRequestMatcher类的典型用法代码示例。如果您正苦于以下问题:Java AntPathRequestMatcher类的具体用法?Java AntPathRequestMatcher怎么用?Java AntPathRequestMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AntPathRequestMatcher类属于org.springframework.security.web.util.matcher包,在下文中一共展示了AntPathRequestMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception{
http.addFilterBefore(characterEncodingFilter(), CsrfFilter.class);
http.authorizeRequests()
.antMatchers("/","/category/**","/article/add","/user/update").access("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN') or hasRole('ROLE_MODERATOR')")
.antMatchers("/admin","/admin/**").access("hasRole('ROLE_ADMIN')")
.and()
.formLogin()
.loginPage("/login")
.usernameParameter("ssoId")
.passwordParameter("password")
.failureHandler(new CustomAuthenticationFailureHandler())
.defaultSuccessUrl("/")
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login?logout").deleteCookies("JSESSIONID")
.invalidateHttpSession(true)
.and()
.rememberMe().tokenRepository(persistentTokenRepository()).tokenValiditySeconds(86400)
.and()
.csrf()
.and()
.exceptionHandling().accessDeniedPage("/error");
http.sessionManagement().maximumSessions(1).sessionRegistry(sessionRegistry());
}
示例2: samlFilter
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Bean
public FilterChainProxy samlFilter() throws Exception {
List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
samlEntryPoint()));
chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
samlLogoutFilter()));
chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
metadataDisplayFilter()));
chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
samlWebSSOProcessingFilter()));
chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSOHoK/**"),
samlWebSSOHoKProcessingFilter()));
chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
samlLogoutProcessingFilter()));
chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"),
samlIDPDiscovery()));
return new FilterChainProxy(chains);
}
示例3: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception
{
// EXAMPLE OF AUTHENTICATION AND AUTHORIZATION
http.csrf().disable().
authorizeRequests()
//TODO: verificar se da pra deixar um matcher só
.antMatchers("/admin").hasRole("ADMIN")
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/cadastro/**").permitAll()
.antMatchers("/evaluate").permitAll()
.antMatchers("/vQtDNoCxpCa8QIAZPWeIMt4hPuLwZ8a/").permitAll()
.antMatchers("/modulo/cultura/missao/deliver").permitAll()
.antMatchers("/entrega/submit").permitAll()
// .antMatchers(HttpMethod.POST,"/specificUrl").hasRole("ADMIN")
// .antMatchers("/url3/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login"). permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"));
}
示例4: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
List<RequestMatcher> csrfMethods = new ArrayList<>();
Arrays.asList( "POST", "PUT", "PATCH", "DELETE" )
.forEach( method -> csrfMethods.add( new AntPathRequestMatcher( "/**", method ) ) );
http
.sessionManagement().sessionCreationPolicy( SessionCreationPolicy.STATELESS ).and()
.exceptionHandling().authenticationEntryPoint( restAuthenticationEntryPoint ).and()
.authorizeRequests()
.antMatchers(
HttpMethod.GET,
"/",
"/webjars/**",
"/*.html",
"/favicon.ico",
"/**/*.html",
"/**/*.css",
"/**/*.js"
).permitAll()
.antMatchers("/auth/**").permitAll()
.anyRequest().authenticated().and()
.addFilterBefore(new TokenAuthenticationFilter(tokenHelper, jwtUserDetailsService), BasicAuthenticationFilter.class);
http.csrf().disable();
}
示例5: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests()
.antMatchers("/", "/login", "/register")
.permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/profile")
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login");
}
示例6: authInterceptor
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Bean
public AuthenticationInterceptor authInterceptor() {
List<RequestMatcher> matchers = ImmutableList.of(
new AntPathRequestMatcher("/flows/**"),
new AntPathRequestMatcher("/user/register"),
new AntPathRequestMatcher("/user/delete"),
new AntPathRequestMatcher("/user"),
new AntPathRequestMatcher("/user/role/update"),
new AntPathRequestMatcher("/jobs/**"),
new AntPathRequestMatcher("/credentials/*"),
new AntPathRequestMatcher("/actions/**"),
new AntPathRequestMatcher("/message/**"),
new AntPathRequestMatcher("/agents/create"),
new AntPathRequestMatcher("/agents"),
new AntPathRequestMatcher("/roles/**"),
new AntPathRequestMatcher("/thread/config")
);
return new AuthenticationInterceptor(matchers);
}
示例7: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception{
http.authorizeRequests()
.antMatchers("/","/category/**","/article/add","/user/update").access("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN') or hasRole('ROLE_MODERATOR')")
.antMatchers("/admin","/admin/**").access("hasRole('ROLE_ADMIN')")
.and()
.formLogin()
.loginPage("/login")
.usernameParameter("ssoId")
.passwordParameter("password")
.failureHandler(new CustomAuthenticationFailureHandler())
.defaultSuccessUrl("/")
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login?logout").deleteCookies("JSESSIONID")
.invalidateHttpSession(true)
.and()
.rememberMe().tokenRepository(persistentTokenRepository()).tokenValiditySeconds(86400)
.and()
.csrf()
.and()
.exceptionHandling().accessDeniedPage("/oups");
http.sessionManagement().maximumSessions(1).sessionRegistry(sessionRegistry());
}
示例8: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/produtos/form").hasRole("ADMIN")
.antMatchers("/shopping/**").permitAll()
.antMatchers(HttpMethod.POST, "/produtos").hasRole("ADMIN")
.antMatchers("/produtos/**").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/user/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").permitAll().successHandler(
new RedirectAfterLogin())
// para definir para onde vai depois de fazer o login
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher(
"/logout"))
.logoutSuccessHandler(new RedirectAfterLogout());
}
示例9: springSecurityFilterChain
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Bean(name = "springSecurityFilterChain")
public FilterChainProxy springSecurityFilterChain() throws ServletException, Exception {
final List<SecurityFilterChain> listOfFilterChains = new ArrayList<SecurityFilterChain>();
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/cors")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/dump")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/validatorUrl")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-resources")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/ui")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/security")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/v2/api-docs")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-ui.html")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/webjars/**")));
// no filters
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/webjars/**")));// no filters
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/*"), securityContextPersistenceFilterWithASCFalse(),
usernamePasswordAuthenticationFilter(), sessionManagementFilter(), exceptionTranslationFilter(), filterSecurityInterceptor()));
final FilterChainProxy filterChainProxy = new FilterChainProxy(listOfFilterChains);
return filterChainProxy;
}
示例10: springSecurityFilterChain
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Bean(name = "springSecurityFilterChain")
public FilterChainProxy springSecurityFilterChain() throws ServletException, Exception {
final List<SecurityFilterChain> listOfFilterChains = new ArrayList<SecurityFilterChain>();
// listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/login"), new NoSecurityFilter()));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/validatorUrl")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-resources")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/ui")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/security")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/v2/api-docs")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-ui.html")));
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/webjars/**")));
// no filters
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/webjars/**")));// no filters
listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/**"), securityContextPersistenceFilterWithASCFalse(),
exceptionTranslationFilter(), filterSecurityInterceptor()));
final FilterChainProxy filterChainProxy = new FilterChainProxy(listOfFilterChains);
return filterChainProxy;
}
示例11: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected void configure(final HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests()
.antMatchers("/fonts/**").permitAll()
.antMatchers("/register").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll()
.and()
.exceptionHandling().accessDeniedPage("/access?error")
.and().headers().xssProtection().block(false).xssProtectionEnabled(false).and() // Default setting for Spring Boot to activate XSS Protection (dont fix!)
.and().csrf().disable(); // FIXME [dh] Enabling CSRF prevents file upload, must be fixed
}
示例12: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
logger.debug("Configuring web security");
http.headers().cacheControl().disable();
http.authorizeRequests()
// TODO (move img to images)
// TODO (move intl to js/intl)
.antMatchers("/intl/*", "/img/*", "/fonts/*", "/webjars/**", "/cli/**").permitAll()
.regexMatchers("/login\\?.*").permitAll()
.anyRequest().fullyAuthenticated()
.and()
.formLogin()
.loginPage("/login").permitAll()
.successHandler(new ShowPageAuthenticationSuccessHandler())
.and()
.logout().logoutSuccessUrl("/login?logout").permitAll();
http.exceptionHandling().defaultAuthenticationEntryPointFor(new Http401AuthenticationEntryPoint("API_UNAUTHORIZED"), new AntPathRequestMatcher("/api/*"));
http.exceptionHandling().defaultAuthenticationEntryPointFor(new LoginUrlAuthenticationEntryPoint("/login"), new AntPathRequestMatcher("/*"));
}
示例13: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests()
.antMatchers("/", "/esparkHome").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/esparkLoginPage")
.defaultSuccessUrl("/esparkUserPage")
.permitAll()
.and()
.csrf().disable()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/esparkHome")
.permitAll();
}
示例14: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests()
.antMatchers("/", "/esparkHome").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/esparkLoginPage")
.defaultSuccessUrl("/esparkUserPage")
.permitAll()
.and()
.csrf().disable()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/esparkHome")
.permitAll();
}
示例15: configure
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests()
.antMatchers("/", "/esparkHome").permitAll()
.antMatchers("/espark/info").hasAnyRole("ADMIN","USER")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/esparkLoginPage")
.defaultSuccessUrl("/esparkUserPage")
.permitAll()
.and()
.csrf().disable()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/esparkHome?logout=true")
.permitAll();
}