security work
This commit is contained in:
parent
56c520a694
commit
1696627374
@ -23,7 +23,7 @@ public class MvcConfig 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("/login.html");
|
||||||
registry.addViewController("/homepage.html");
|
registry.addViewController("/homepage.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,31 @@
|
|||||||
<?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"
|
||||||
xmlns:sec="http://www.springframework.org/schema/security"
|
|
||||||
xsi:schemaLocation="
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/security
|
http://www.springframework.org/schema/security
|
||||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||||
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||||
|
|
||||||
<http use-expressions="true" entry-point-ref="restAuthenticationEntryPoint">
|
<http use-expressions="true">
|
||||||
<intercept-url pattern="/api/**" access="isAuthenticated()" />
|
<intercept-url pattern="/anonymous*" access="isAnonymous()" />
|
||||||
|
<intercept-url pattern="/login*" access="permitAll" />
|
||||||
|
<intercept-url pattern="/**" access="isAuthenticated()" />
|
||||||
|
|
||||||
<sec:form-login authentication-success-handler-ref="mySuccessHandler" />
|
<form-login login-page='/login.html' login-processing-url="/perform_login" default-target-url="/homepage.html" authentication-failure-url="/login.html?error=true"
|
||||||
|
always-use-default-target="true" />
|
||||||
|
|
||||||
<logout />
|
|
||||||
</http>
|
</http>
|
||||||
|
|
||||||
<beans:bean id="mySuccessHandler" class="org.baeldung.security.MySavedRequestAwareAuthenticationSuccessHandler" />
|
|
||||||
|
|
||||||
<authentication-manager>
|
<authentication-manager>
|
||||||
<authentication-provider ref="customAuthenticationProvider" />
|
<authentication-provider>
|
||||||
|
<user-service>
|
||||||
|
<user name="user1" password="user1Pass" authorities="ROLE_USER" />
|
||||||
|
</user-service>
|
||||||
|
</authentication-provider>
|
||||||
</authentication-manager>
|
</authentication-manager>
|
||||||
|
|
||||||
|
<!-- <authentication-manager> -->
|
||||||
|
<!-- <authentication-provider ref="customAuthenticationProvider" /> -->
|
||||||
|
<!-- </authentication-manager> -->
|
||||||
|
|
||||||
</beans:beans>
|
</beans:beans>
|
@ -0,0 +1,26 @@
|
|||||||
|
<html>
|
||||||
|
<head></head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Login</h1>
|
||||||
|
|
||||||
|
<form name='f' action="perform_login" method='POST'>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>User:</td>
|
||||||
|
<td><input type='text' name='j_username' value=''></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Password:</td>
|
||||||
|
<td><input type='password' name='j_password' /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><input name="submit" type="submit" value="submit" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -2,16 +2,14 @@
|
|||||||
<beans:beans xmlns="http://www.springframework.org/schema/security"
|
<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"
|
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/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
<debug/>
|
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||||
|
|
||||||
<http use-expressions="true" >
|
<http use-expressions="true" >
|
||||||
<intercept-url pattern="/anonymous*" access="isAnonymous()" />
|
<intercept-url pattern="/anonymous*" access="isAnonymous()" />
|
||||||
|
|
||||||
<intercept-url pattern="/login*" access="permitAll" />
|
<intercept-url pattern="/login*" access="permitAll" />
|
||||||
|
|
||||||
<intercept-url pattern="/**" access="isAuthenticated()" />
|
<intercept-url pattern="/**" access="isAuthenticated()" />
|
||||||
|
|
||||||
<form-login
|
<form-login
|
||||||
@ -28,7 +26,7 @@
|
|||||||
|
|
||||||
</http>
|
</http>
|
||||||
|
|
||||||
<beans:bean name="customLogoutSuccessHandler" class="org.baeldung.spring.security.CustomLogoutSuccessHandler" />
|
<beans:bean name="customLogoutSuccessHandler" class="org.baeldung.security.CustomLogoutSuccessHandler" />
|
||||||
|
|
||||||
<authentication-manager>
|
<authentication-manager>
|
||||||
<authentication-provider>
|
<authentication-provider>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user