org.springframework.boot.autoconfigure.security.servlet.PathRequest Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.security.servlet.PathRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecurityConfig.java    From influx-proxy with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(WebSecurity web) throws Exception {
    List<String> ignore = Arrays.asList("/health", "/actuator/**");
    web.
            ignoring()
            .requestMatchers(PathRequest.toStaticResources().atCommonLocations())
            .antMatchers(ignore.toArray(new String[0]))
            .antMatchers("/api/**");
}
 
Example #2
Source File: SecurityConfig.java    From streaming-file-server with MIT License 5 votes vote down vote up
@Override protected void configure(final HttpSecurity http) throws Exception {
  // @formatter:off
  http
      .authorizeRequests()
        /*
        .requestMatchers()
          .antMatchers("/actuator/health")
            .permitAll()
        */
        .requestMatchers(EndpointRequest.to("status", "info", "health"))
          .permitAll()
        .requestMatchers(PathRequest.toStaticResources().atCommonLocations())
          .permitAll()
        .anyRequest()
          .authenticated()
      .and()
        .formLogin()
          .disable()
      .headers()
        .frameOptions()
          .sameOrigin()
      .and()
        .csrf()
          .disable()
        .httpBasic()
      .and()
        .logout()
          .logoutUrl("/disconnect")
          .clearAuthentication(true)
          .invalidateHttpSession(true)
          .permitAll()
  ;
  // @formatter:on
}
 
Example #3
Source File: WebSecurityConfig.java    From POC with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http.authorizeRequests().antMatchers(HttpMethod.GET, "/").permitAll()
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll().antMatchers("/login")
			.permitAll().antMatchers("/signup").permitAll().antMatchers("/dashboard/**").hasAuthority("ADMIN")
			.anyRequest().authenticated().and().csrf().disable().formLogin()
			.successHandler(this.customizeAuthenticationSuccessHandler).loginPage("/login")
			.failureUrl("/login?error=true").usernameParameter("email").passwordParameter("password").and().logout()
			.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/").and()
			.exceptionHandling();
}
 
Example #4
Source File: SecurityConfig.java    From POC with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http.csrf().disable().authorizeRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll()
			.requestMatchers(EndpointRequest.toAnyEndpoint().excluding(MappingsEndpoint.class)).hasRole("ACTUATOR")
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.antMatchers(HttpMethod.OPTIONS, "/**").permitAll().antMatchers(HttpMethod.GET, "/ping").permitAll()
			.antMatchers(HttpMethod.DELETE, "/**").hasRole("ADMIN").antMatchers("/**").hasRole("USER").and()
			.httpBasic();
	// H2 database console runs inside a frame, So we need to disable X-Frame-Options
	// in Spring Security.
	http.headers().frameOptions().disable();
}
 
Example #5
Source File: WebSecurityConfig.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http
		.authorizeRequests((authorize) -> authorize
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.anyRequest().authenticated()
		)
		.formLogin((formLogin) -> formLogin
			.permitAll()
		);
}
 
Example #6
Source File: SecurityConfig.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http
		.authorizeRequests((authorize) -> authorize
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.anyRequest().authenticated()
		)
		.formLogin((formLogin) -> formLogin
			.loginPage("/login")
			.permitAll()
		);
}
 
Example #7
Source File: SecurityConfig.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http
		.authorizeRequests((authorize) -> authorize
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.anyRequest().authenticated()
		)
		.formLogin((formLogin) -> formLogin
			.permitAll()
		);
}
 
Example #8
Source File: SecurityConfig.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http
		.authorizeRequests((authorize) -> authorize
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.anyRequest().authenticated()
		)
		.formLogin((formLogin) -> formLogin
			.loginPage("/login")
			.permitAll()
		);
}
 
Example #9
Source File: SecurityConfig.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http
		.authorizeRequests((authorize) -> authorize
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.anyRequest().authenticated()
		)
		.formLogin((formLogin) -> formLogin
			.permitAll()
		);
}
 
Example #10
Source File: SecurityConfig.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	http
		.authorizeRequests((authorize) -> authorize
			.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.anyRequest().authenticated()
		)
		.formLogin((formLogin) -> formLogin
			.permitAll()
		);
}
 
Example #11
Source File: WebSecurityConfig.java    From spring-session with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(WebSecurity web) {
	web
		.ignoring().requestMatchers(PathRequest.toH2Console());
}
 
Example #12
Source File: SecurityConfig.java    From spring-session with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(WebSecurity web) {
	web
		.ignoring().requestMatchers(PathRequest.toH2Console());
}