| 25976 |
amit.gupta |
1 |
package com.spice.profitmandi.web.config;
|
|
|
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 |
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
| 26310 |
amit.gupta |
13 |
|
| 25976 |
amit.gupta |
14 |
@Autowired
|
|
|
15 |
private MyBasicAuthenticationEntryPoint myBasicAuthenticationEntryPoint;
|
|
|
16 |
|
| 26310 |
amit.gupta |
17 |
/*@Override
|
| 25976 |
amit.gupta |
18 |
public void configure(WebSecurity web) throws Exception {
|
|
|
19 |
web.ignoring().anyRequest();
|
| 26310 |
amit.gupta |
20 |
}*/
|
| 25976 |
amit.gupta |
21 |
|
|
|
22 |
@Override
|
|
|
23 |
protected void configure(HttpSecurity http) throws Exception {
|
| 26313 |
amit.gupta |
24 |
http.
|
| 26314 |
amit.gupta |
25 |
logout().logoutUrl("logmeout").and()
|
| 26313 |
amit.gupta |
26 |
.cors().disable().csrf().disable()
|
| 26310 |
amit.gupta |
27 |
.authorizeRequests()
|
|
|
28 |
//.antMatchers("/**").hasRole("hdfc")
|
|
|
29 |
.antMatchers("/hdfc/**").hasRole("hdfc")
|
|
|
30 |
.antMatchers("/hdfctest/**").hasRole("hdfctest")
|
|
|
31 |
.antMatchers("/**").permitAll()
|
|
|
32 |
.and()
|
|
|
33 |
.httpBasic()
|
|
|
34 |
.authenticationEntryPoint(myBasicAuthenticationEntryPoint);
|
| 25976 |
amit.gupta |
35 |
}
|
|
|
36 |
|
| 26310 |
amit.gupta |
37 |
@Autowired
|
|
|
38 |
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
|
|
39 |
auth.inMemoryAuthentication().withUser("hdfcuser").password("sd123$%^aGg").roles("hdfc").and()
|
|
|
40 |
.withUser("hdfctestuser").password("test").roles("hdfctest");
|
| 25976 |
amit.gupta |
41 |
}
|
|
|
42 |
|
|
|
43 |
}
|