Subversion Repositories SmartDukaan

Rev

Rev 25976 | Rev 26313 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 {
26310 amit.gupta 24
		http.cors().disable().csrf().disable()
25
				.authorizeRequests()
26
				//.antMatchers("/**").hasRole("hdfc")
27
				.antMatchers("/hdfc/**").hasRole("hdfc")
28
				.antMatchers("/hdfctest/**").hasRole("hdfctest")
29
				.antMatchers("/**").permitAll()
30
				.and()
31
				.httpBasic()
32
				.authenticationEntryPoint(myBasicAuthenticationEntryPoint);
25976 amit.gupta 33
	}
34
 
26310 amit.gupta 35
	@Autowired
36
	protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
37
		auth.inMemoryAuthentication().withUser("hdfcuser").password("sd123$%^aGg").roles("hdfc").and()
38
				.withUser("hdfctestuser").password("test").roles("hdfctest");
25976 amit.gupta 39
	}
40
 
41
}