org.springframework.security.config.web.server.HttpSecurity Java Examples

The following examples show how to use org.springframework.security.config.web.server.HttpSecurity. 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: SecurityConfiguration.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@Bean
SecurityWebFilterChain springWebFilterChain() {
	return HttpSecurity.http()
		.securityContextRepository(
			new WebSessionSecurityContextRepository())
		.authorizeExchange()
			.anyExchange().authenticated()
			.and()
		.build();
}
 
Example #2
Source File: SecurityConfiguration.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@Bean
SecurityWebFilterChain springWebFilterChain() {
	return HttpSecurity.http()
		.securityContextRepository(new WebSessionSecurityContextRepository())
		.authorizeExchange()
		.anyExchange().authenticated()
		.and()
		.build();
}
 
Example #3
Source File: SecurityConfiguration.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@Bean
SecurityWebFilterChain springWebFilterChain(HttpSecurity http) {
	return http
		.authorizeExchange()
			.pathMatchers("/**").authenticated()
			.and()
		.build();
}
 
Example #4
Source File: SecurityConfiguration.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@Bean
SecurityWebFilterChain springWebFilterChain() {
	return HttpSecurity.http()
		.securityContextRepository(
			new WebSessionSecurityContextRepository())
		.authorizeExchange()
			.anyExchange().authenticated()
			.and()
		.build();
}
 
Example #5
Source File: SecurityConfiguration.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@Bean
SecurityWebFilterChain springWebFilterChain() {
	return HttpSecurity.http()
		.securityContextRepository(new WebSessionSecurityContextRepository())
		.authorizeExchange()
		.anyExchange().authenticated()
		.and()
		.build();
}
 
Example #6
Source File: SecurityConfiguration.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@Bean
SecurityWebFilterChain springWebFilterChain(HttpSecurity http) {
	return http
		.authorizeExchange()
		.pathMatchers("/**").authenticated()
		.and()
		.build();
}
 
Example #7
Source File: SecurityConfig.java    From spring-5-examples with MIT License 5 votes vote down vote up
/**
 * Authorization
 */

@Bean
SecurityWebFilterChain springWebFilterChain(HttpSecurity http) throws Exception {
  return http
      .authorizeExchange()
        .pathMatchers("/all/{usernamePathVariable}").access(this::currentUserMatchesRoleAndPath)
        .pathMatchers("/first").access(this::currentUserMatchesRole)
        .pathMatchers("/**").hasRole(ROLE_ADMIN)
      .anyExchange().authenticated()
      .and()
      ////not necessary, already injected
      //.authenticationManager(reactiveAuthenticationManager(userDetailsRepository()))
      .build();
}
 
Example #8
Source File: SecurityConfig.java    From spring-5-examples with MIT License 5 votes vote down vote up
WebFilter securityFilterChainJustRoleWay(final ReactiveAuthenticationManager reactiveAuthenticationManager) {

    return HttpSecurity.http()
                       .authorizeExchange()
                         .pathMatchers("/**")
                         .hasRole("ADMIN")
                       .and()
                       .httpBasic()
                       .authenticationManager(reactiveAuthenticationManager)
                       .build();
  }
 
Example #9
Source File: Application.java    From spring-security-reactive with Apache License 2.0 5 votes vote down vote up
@Bean
WebFilter springSecurityFilterChain(ReactiveAuthenticationManager manager) throws Exception {
	HttpSecurity http = http();
	// FIXME use BeanPostProcessor to set the manager
	http.authenticationManager(manager);
	http.httpBasic();

	AuthorizeRequestBuilder authorize = http.authorizeRequests();
	authorize.antMatchers("/admin/**").hasRole("ADMIN");
	authorize.anyExchange().authenticated();
	return http.build();
}