diff --git a/.gitignore b/.gitignore index e56d60133e..3edb6888c2 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ build/ *.iws .gradle/ atlassian-ide-plugin.xml +/samples diff --git a/build.gradle b/build.gradle index 7c8906519d..43abb1f7ed 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ allprojects { group = 'org.springframework.security' repositories { + mavenCentral() maven { url "http://repo.springsource.org/plugins-release" } maven { url "http://repo.terracotta.org/maven2/" } } diff --git a/docs/guides/src/asciidoc/_hello-includes/secure-the-application.asc b/docs/guides/src/asciidoc/_hello-includes/secure-the-application.asc index 22dbe14a99..95f4463d3b 100644 --- a/docs/guides/src/asciidoc/_hello-includes/secure-the-application.asc +++ b/docs/guides/src/asciidoc/_hello-includes/secure-the-application.asc @@ -50,8 +50,6 @@ The next step is to create a Spring Security configuration. ---- package org.springframework.security.samples.config; -import org.springframework.beans.factory.annotation.Autowired; - import org.springframework.context.annotation.*; import org.springframework.security.config.annotation.authentication.builders.*; import org.springframework.security.config.annotation.web.configuration.*; diff --git a/docs/guides/src/asciidoc/form.asc b/docs/guides/src/asciidoc/form.asc index 3037ea2462..66ea0b6770 100644 --- a/docs/guides/src/asciidoc/form.asc +++ b/docs/guides/src/asciidoc/form.asc @@ -150,65 +150,48 @@ public class WebMvcConfiguration extends WebMvcConfigurerAdapter { registry.addViewController("/login").setViewName("login"); registry.setOrder(Ordered.HIGHEST_PRECEDENCE); } - - @Bean - public InternalResourceViewResolver jspxViewResolver() { - InternalResourceViewResolver result = new InternalResourceViewResolver(); - result.setPrefix("/WEB-INF/views/"); - result.setSuffix(".jspx"); - return result; - } } ---- == Creating a login view -Our existing configuration means that all we need to do is create a *login.jspx* file with the following contents: +Our existing configuration means that all we need to do is create a *login.html* file with the following contents: -.src/main/webapp/WEB-INF/views/login.jspx +.src/main/resources/views/login.html [source,xml] ---- - - - - -Please Login - - - - <1> -
- Please Login - <2> -
+ + + Messages : Create + + +
+
<1> +
+ Please Login +
<2> Invalid username and password.
- - <3> -
+
<3> You have been logged out.
- - - <4> - - <5> -
- -
-
- - + + <4> + + <5> +
+ +
+
+ + + -
---- <1> The URL we submit our username and password to is the same URL as our login form (i.e. */login*), but a *POST* instead of a *GET*. <2> When authentication fails, the browser is redirected to */login?error* so we can display an error message by detecting if the parameter *error* is non-null. -<3> When we are successfully loged out, the browser is redirected to */login?logout* so we can display an logout success message by detecting if the parameter *logout* is non-null. +<3> When we are successfully logged out, the browser is redirected to */login?logout* so we can display an logout success message by detecting if the parameter *logout* is non-null. <4> The username should be present on the HTTP parameter username <5> The password should be present on the HTTP parameter password diff --git a/docs/guides/src/asciidoc/hellomvc.asc b/docs/guides/src/asciidoc/hellomvc.asc index ea33f4b9b2..36e224a989 100644 --- a/docs/guides/src/asciidoc/hellomvc.asc +++ b/docs/guides/src/asciidoc/hellomvc.asc @@ -34,16 +34,14 @@ We have created the Spring Security configuration, but we still need to register ---- package org.springframework.security.samples.config; -import org.springframework.core.annotation.*; import org.springframework.security.web.context.*; -@Order(2) public class MessageSecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { } ---- -The `MessageSecurityWebApplicationInitializer` will automatically register the springSecurityFilterChain Filter for every URL in your application. We add `@Order(2)` so the springSecurityFilterChain is inserted before our Sitemesh Filter declared in <> +The `MessageSecurityWebApplicationInitializer` will automatically register the springSecurityFilterChain Filter for every URL in your application. If Filters are added within other `WebApplicationInitializer` instances we can use `@Order` to control the ordering of the Filter instances. === Verify SecurityConfig is loaded @@ -53,7 +51,6 @@ Just because <> exists, does not mean that .MessageWebApplicationInitializer.java [source,java] ---- -@Order(1) public class MessageWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @@ -86,64 +83,39 @@ include::{hello-include-dir}/exploring-the-secured-application.asc[] ==== Displaying the user name -Now that we have authenticated, let's update the application to display the username if the user is authenticated. Update main.jsp to contain the following snippet: +Now that we have authenticated, let's see how our application is displaying the username if the user is authenticated. -.src/main/webapp/WEB-INF/decorators/main.jsp +.messages-jc/src/main/resources/views/layout.html [source,html] -[subs="verbatim,quotes"] ---- -