1
I’m trying to implement Spring Security...only that I’m having trouble with its configuration, @Override doesn’t work at all, and because of that it doesn’t take the user created in memory, let alone change the default permission settings and such.
I created a new project only with SPRING MVC+ Soring Boot + Spring Security, just to see if I can use it, the more the problem persists.
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic();
}
@Bean
@Override
public UserDetailsService userDetailsService() {
UserDetails user = User.builder()
.username("user")
.password("user")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
}
build.Gradle
plugins {
id 'org.springframework.boot' version '2.4.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
I don’t know if some configuration is missing, more for what I’ve been researching, this basic configuration there, should appear an Alert to put the login I created in memory....
When I run the project creates the default Spring password and the login screen is a cute web screen, not an Alert.