Use xml / javaconfig folders for samples
Fixes gh-3752
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
= Creating a Custom Login Form
|
||||
:author: Rob Winch
|
||||
:starter-appname: hellomvc-jc
|
||||
:completed-appname: form-jc
|
||||
:starter-appname: javaconfig/hellomvc
|
||||
:completed-appname: javaconfig/form
|
||||
:include-dir: _includes
|
||||
|
||||
This guide builds off of link:hellomvc.html[Hello Spring MVC Security Java Config] to explain how to configure and use a custom login form with Spring Security Java Configuration.
|
||||
@@ -133,7 +133,7 @@ Within Spring Web MVC there are two steps to creating our login page:
|
||||
|
||||
== Configuring a login view controller
|
||||
|
||||
Within Spring Web MVC, the first step is to ensure that we have a controller that can point to our view. Since our project adds the *messages-jc* project as a dependency and it contains a view controller for */login* we do not need to create a controller within our application. For reference, you can see the configuration below:
|
||||
Within Spring Web MVC, the first step is to ensure that we have a controller that can point to our view. Since our project adds the *javaconfig/messages* project as a dependency and it contains a view controller for */login* we do not need to create a controller within our application. For reference, you can see the configuration below:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
= Hello Spring MVC Security Java Config
|
||||
:author: Rob Winch
|
||||
:starter-appname: insecuremvc
|
||||
:completed-appname: hellomvc-jc
|
||||
:completed-appname: javaconfig/hellomvc
|
||||
:include-dir: _includes
|
||||
:hello-include-dir: _hello-includes
|
||||
|
||||
@@ -45,7 +45,7 @@ The `MessageSecurityWebApplicationInitializer` will automatically register the s
|
||||
|
||||
=== Verify SecurityConfig is loaded
|
||||
|
||||
Just because <<security-config-java,SecurityConfig>> exists, does not mean that our Spring application knows about it. In this instance, our Spring root application context is initialized using MessageWebApplicationInitializer which is included with our spring-security-samples-messages-jc project. You can find a snippet of it below:
|
||||
Just because <<security-config-java,SecurityConfig>> exists, does not mean that our Spring application knows about it. In this instance, our Spring root application context is initialized using MessageWebApplicationInitializer which is included with our spring-security-samples-javaconfig-messages project. You can find a snippet of it below:
|
||||
|
||||
[[message-web-application-inititializer-java]]
|
||||
.MessageWebApplicationInitializer.java
|
||||
@@ -63,7 +63,7 @@ public class MessageWebApplicationInitializer extends
|
||||
}
|
||||
----
|
||||
|
||||
You will notice it is loading the `RootConfiguration` class which is also included in our spring-security-samples-messages-jc project.
|
||||
You will notice it is loading the `RootConfiguration` class which is also included in our spring-security-samples-javaconfig-messages project.
|
||||
|
||||
[[root-configuration-java]]
|
||||
.RootConfiguration.java
|
||||
@@ -85,7 +85,7 @@ include::{hello-include-dir}/exploring-the-secured-application.asc[]
|
||||
|
||||
Now that we have authenticated, let's see how our application is displaying the username if the user is authenticated.
|
||||
|
||||
.messages-jc/src/main/resources/views/layout.html
|
||||
.messages/src/main/resources/views/layout.html
|
||||
[source,html]
|
||||
----
|
||||
<div th:if="${#httpServletRequest.remoteUser != null}">
|
||||
@@ -103,7 +103,7 @@ WARNING: The Thymeleaf ensures the username is escaped to avoid http://en.wikipe
|
||||
|
||||
We can view the user name, but how are we able to log out? Below you can see how we are able to log out.
|
||||
|
||||
.messages-jc/src/main/resources/views/layout.html
|
||||
.messages/src/main/resources/views/layout.html
|
||||
[source,html]
|
||||
----
|
||||
<form th:action="@{/logout}" method="post">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
= Hello Spring Security Java Config
|
||||
:author: Rob Winch
|
||||
:starter-appname: insecure
|
||||
:completed-appname: helloworld-jc
|
||||
:completed-appname: javaconfig/helloworld
|
||||
:include-dir: _includes
|
||||
:hello-include-dir: _hello-includes
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Spring Security 4 added support for securing http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html[Spring's WebSocket support].
|
||||
This section describes how to use Spring Security's WebSocket support.
|
||||
|
||||
NOTE: You can find a complete working sample of WebSocket security in samples/chat-jc.
|
||||
NOTE: You can find a complete working sample of WebSocket security in samples/javaconfig/chat.
|
||||
|
||||
.Direct JSR-356 Support
|
||||
****
|
||||
|
||||
@@ -766,7 +766,7 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception
|
||||
[[jc-authentication-jdbc]]
|
||||
==== JDBC Authentication
|
||||
|
||||
You can find the updates to suppport JDBC based authentication. The example below assumes that you have already defined a `DataSource` within your application. The https://github.com/spring-projects/spring-security/tree/master/samples/jdbc-jc[jdbc-jc sample] provides a complete example of using JDBC based authentication.
|
||||
You can find the updates to suppport JDBC based authentication. The example below assumes that you have already defined a `DataSource` within your application. The https://github.com/spring-projects/spring-security/tree/master/samples/javaconfig/jdbc[jdbc-javaconfig] sample provides a complete example of using JDBC based authentication.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@@ -786,7 +786,7 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception
|
||||
|
||||
==== LDAP Authentication
|
||||
|
||||
You can find the updates to suppport LDAP based authentication. The https://github.com/spring-projects/spring-security/tree/master/samples/ldap-jc[ldap-jc sample] provides a complete example of using LDAP based authentication.
|
||||
You can find the updates to suppport LDAP based authentication. The https://github.com/spring-projects/spring-security/tree/master/samples/javaconfig/ldap[ldap-javaconfig] sample provides a complete example of using LDAP based authentication.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@@ -2728,7 +2728,7 @@ If authentication fails, the configured `AuthenticationFailureHandler` will be i
|
||||
|
||||
[[servletapi]]
|
||||
== Servlet API integration
|
||||
This section describes how Spring Security is integrated with the Servlet API. The https://github.com/spring-projects/spring-security/tree/master/samples/servletapi-xml[servletapi-xml] sample application demonstrates the usage of each of these methods.
|
||||
This section describes how Spring Security is integrated with the Servlet API. The https://github.com/spring-projects/spring-security/tree/master/samples/xml/servletapi[servletapi-xml] sample application demonstrates the usage of each of these methods.
|
||||
|
||||
|
||||
[[servletapi-25]]
|
||||
@@ -5252,7 +5252,7 @@ We've assumed here that the <<ns-config,security namespace>> is being used for c
|
||||
==== Java EE Container Authentication
|
||||
The class `J2eePreAuthenticatedProcessingFilter` will extract the username from the `userPrincipal` property of the `HttpServletRequest`. Use of this filter would usually be combined with the use of Java EE roles as described above in <<j2ee-preauth-details>>.
|
||||
|
||||
There is a sample application in the codebase which uses this approach, so get hold of the code from github and have a look at the application context file if you are interested. The code is in the `samples/preauth-xml` directory.
|
||||
There is a sample application in the codebase which uses this approach, so get hold of the code from github and have a look at the application context file if you are interested. The code is in the `samples/xml/preauth` directory.
|
||||
|
||||
|
||||
[[ldap]]
|
||||
|
||||
Reference in New Issue
Block a user