| 1 | |
package com.ctrip.framework.apollo.common.controller; |
| 2 | |
|
| 3 | |
import org.springframework.beans.factory.annotation.Autowired; |
| 4 | |
import org.springframework.context.annotation.Configuration; |
| 5 | |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
| 6 | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| 7 | |
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
| 8 | |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| 9 | |
|
| 10 | |
@Configuration |
| 11 | |
@EnableWebSecurity |
| 12 | 0 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| 13 | |
|
| 14 | |
@Override |
| 15 | |
protected void configure(HttpSecurity http) throws Exception { |
| 16 | 0 | http.httpBasic(); |
| 17 | 0 | http.csrf().disable(); |
| 18 | 0 | } |
| 19 | |
|
| 20 | |
@Autowired |
| 21 | |
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { |
| 22 | 0 | auth.inMemoryAuthentication().withUser("user").password("").roles("USER").and() |
| 23 | 0 | .withUser("apollo").password("").roles("USER", "ADMIN"); |
| 24 | 0 | } |
| 25 | |
} |