security work
This commit is contained in:
parent
47bfc87401
commit
dd8debd720
|
@ -11,9 +11,9 @@ import org.springframework.web.servlet.view.JstlView;
|
||||||
|
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ClientWebConfig extends WebMvcConfigurerAdapter {
|
public class FrontendConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
public ClientWebConfig() {
|
public FrontendConfig() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ public class ClientWebConfig extends WebMvcConfigurerAdapter {
|
||||||
public void addViewControllers(final ViewControllerRegistry registry) {
|
public void addViewControllers(final ViewControllerRegistry registry) {
|
||||||
super.addViewControllers(registry);
|
super.addViewControllers(registry);
|
||||||
|
|
||||||
registry.addViewController("/login.html");
|
|
||||||
registry.addViewController("/homepage.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,17 +1,24 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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"
|
<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="
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
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://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||||
|
|
||||||
|
|
||||||
<http use-expressions="true">
|
<http use-expressions="true">
|
||||||
<intercept-url pattern="/login*" access="isAnonymous()" />
|
<intercept-url pattern="/login*" access="isAnonymous()" />
|
||||||
|
|
||||||
|
<intercept-url pattern="/permitAll" access="permitAll" />
|
||||||
|
|
||||||
<intercept-url pattern="/**" access="isAuthenticated()" />
|
<intercept-url pattern="/**" access="isAuthenticated()" />
|
||||||
|
|
||||||
<http-basic />
|
<http-basic />
|
||||||
|
|
||||||
</http>
|
</http>
|
||||||
|
|
||||||
|
<http pattern="/securityNone" security="none" />
|
||||||
|
|
||||||
<authentication-manager>
|
<authentication-manager>
|
||||||
<authentication-provider>
|
<authentication-provider>
|
||||||
<user-service>
|
<user-service>
|
||||||
|
|
Loading…
Reference in New Issue