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