| 25976 |
amit.gupta |
1 |
package com.spice.profitmandi.web.config;
|
|
|
2 |
|
|
|
3 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
4 |
import org.springframework.beans.factory.annotation.Value;
|
|
|
5 |
import org.springframework.context.annotation.Configuration;
|
|
|
6 |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
|
|
7 |
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
|
8 |
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
|
|
9 |
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
|
10 |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
|
11 |
|
|
|
12 |
@Configuration
|
|
|
13 |
@EnableWebSecurity
|
|
|
14 |
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
15 |
|
|
|
16 |
@Autowired
|
|
|
17 |
private MyBasicAuthenticationEntryPoint myBasicAuthenticationEntryPoint;
|
|
|
18 |
|
|
|
19 |
@Override
|
|
|
20 |
public void configure(WebSecurity web) throws Exception {
|
|
|
21 |
web.ignoring().anyRequest();
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
@Override
|
|
|
25 |
protected void configure(HttpSecurity http) throws Exception {
|
|
|
26 |
http.authorizeRequests().antMatchers("/hdfc/**").hasRole("hdfc")
|
|
|
27 |
.antMatchers("/hdfctest/**").hasRole("hdfctest").and()
|
|
|
28 |
// Possibly more configuration ...
|
|
|
29 |
.httpBasic().authenticationEntryPoint(myBasicAuthenticationEntryPoint);
|
|
|
30 |
// set permitAll for all URLs associated with Form Login
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
@Override
|
|
|
34 |
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
|
|
35 |
auth.inMemoryAuthentication()
|
|
|
36 |
.withUser("hdfcuser").password("sd123$%^aGg").roles("hdfc").and()
|
|
|
37 |
.withUser("hdfctestuser").password("test").roles("hdfctest");
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
}
|