-
Notifications
You must be signed in to change notification settings - Fork 60
/
WebSecurityConfig.java
30 lines (26 loc) · 1.04 KB
/
WebSecurityConfig.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 de.jonashackt.configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
/*
* Enable x509 client authentication.
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http.x509();
}
/*
* Create an in-memory authentication manager. We create 1 user (localhost which
* is the CN of the client certificate) which has a role of USER.
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("localhost")
.password("none")
.roles("USER");
}
}