security work
This commit is contained in:
parent
47bfc87401
commit
dd8debd720
|
@ -11,9 +11,9 @@ import org.springframework.web.servlet.view.JstlView;
|
|||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
public class ClientWebConfig extends WebMvcConfigurerAdapter {
|
||||
public class FrontendConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
public ClientWebConfig() {
|
||||
public FrontendConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ public class ClientWebConfig extends WebMvcConfigurerAdapter {
|
|||
public void addViewControllers(final ViewControllerRegistry registry) {
|
||||
super.addViewControllers(registry);
|
||||
|
||||
registry.addViewController("/login.html");
|
||||
registry.addViewController("/homepage.html");
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.baeldung.spring.web.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.spring.web.controller")
|
||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
public WebConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.baeldung.spring.web.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
public class TestController {
|
||||
|
||||
public TestController() {
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
@RequestMapping("/permitAll")
|
||||
@ResponseBody
|
||||
public String permitAll() {
|
||||
return "Permit All";
|
||||
}
|
||||
|
||||
@RequestMapping("/securityNone")
|
||||
@ResponseBody
|
||||
public String securityNone() {
|
||||
return "Security None";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/security"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||
|
||||
<http use-expressions="true">
|
||||
<intercept-url pattern="/login*" access="isAnonymous()" />
|
||||
<intercept-url pattern="/**" access="isAuthenticated()" />
|
||||
|
||||
<http-basic />
|
||||
|
||||
</http>
|
||||
<http use-expressions="true">
|
||||
<intercept-url pattern="/login*" access="isAnonymous()" />
|
||||
|
||||
<authentication-manager>
|
||||
<authentication-provider>
|
||||
<user-service>
|
||||
<user name="user1" password="user1Pass" authorities="ROLE_USER" />
|
||||
</user-service>
|
||||
</authentication-provider>
|
||||
</authentication-manager>
|
||||
<intercept-url pattern="/permitAll" access="permitAll" />
|
||||
|
||||
<intercept-url pattern="/**" access="isAuthenticated()" />
|
||||
|
||||
<http-basic />
|
||||
|
||||
</http>
|
||||
|
||||
<http pattern="/securityNone" security="none" />
|
||||
|
||||
<authentication-manager>
|
||||
<authentication-provider>
|
||||
<user-service>
|
||||
<user name="user1" password="user1Pass" authorities="ROLE_USER" />
|
||||
</user-service>
|
||||
</authentication-provider>
|
||||
</authentication-manager>
|
||||
|
||||
</beans:beans>
|
Loading…
Reference in New Issue