use of org.springframework.boot.autoconfigure.security.SecurityProperties in project cas by apereo.
the class EndpointLdapAuthenticationProviderDefaultRolesTests method verifyAuthorizedByRole.
@Test
public void verifyAuthorizedByRole() {
val securityProperties = new SecurityProperties();
securityProperties.getUser().setRoles(List.of("ROLE_888"));
val ldap = casProperties.getMonitor().getEndpoints().getLdap();
val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
val authenticator = LdapUtils.newLdaptiveAuthenticator(ldap);
val provider = new EndpointLdapAuthenticationProvider(ldap, securityProperties, connectionFactory, authenticator);
assertThrows(InsufficientAuthenticationException.class, () -> provider.authenticate(new UsernamePasswordAuthenticationToken("authzcas", null)));
val token = provider.authenticate(new UsernamePasswordAuthenticationToken("authzcas", "123456"));
assertNotNull(token);
}
use of org.springframework.boot.autoconfigure.security.SecurityProperties in project cas by apereo.
the class EndpointLdapAuthenticationProviderRolesBasedTests method verifyUserNotFound.
@Test
public void verifyUserNotFound() {
val securityProperties = new SecurityProperties();
securityProperties.getUser().setRoles(List.of("SOME_BAD_ROLE"));
val ldap = casProperties.getMonitor().getEndpoints().getLdap();
val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
val authenticator = LdapUtils.newLdaptiveAuthenticator(ldap);
val provider = new EndpointLdapAuthenticationProvider(ldap, securityProperties, connectionFactory, authenticator);
assertThrows(InsufficientAuthenticationException.class, () -> provider.authenticate(new UsernamePasswordAuthenticationToken("UNKNOWN_USER", "123456")));
assertAll(provider::destroy);
}
use of org.springframework.boot.autoconfigure.security.SecurityProperties in project spring-boot by spring-projects.
the class ReactiveUserDetailsServiceAutoConfiguration method reactiveUserDetailsService.
@Bean
public MapReactiveUserDetailsService reactiveUserDetailsService(SecurityProperties properties, ObjectProvider<PasswordEncoder> passwordEncoder) {
SecurityProperties.User user = properties.getUser();
UserDetails userDetails = getUserDetails(user, getOrDeducePassword(user, passwordEncoder.getIfAvailable()));
return new MapReactiveUserDetailsService(userDetails);
}
Aggregations