Subversion Repositories SmartDukaan

Rev

Rev 25976 | Rev 26313 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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