-
Notifications
You must be signed in to change notification settings - Fork 0
/
SecurityConfiguration.java
30 lines (26 loc) · 1.29 KB
/
SecurityConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.example.preauth;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@Configuration
// when this annotation is present there is an exception:
// Found more than one annotation of type interface org.springframework.security.access.prepost.PreAuthorize
@EnableMethodSecurity(jsr250Enabled = true)
// when this deprecated annotation is present there is no exception and everything works just fine
// @EnableGlobalMethodSecurity(jsr250Enabled = true, prePostEnabled = true)
public class SecurityConfiguration {
@Bean
public UserDetailsService users() {
UserDetails user = User.builder()
.username("user")
.password("{noop}pass")
.roles("ABC")
.build();
return new InMemoryUserDetailsManager(user);
}
}