{"id":16842,"date":"2013-05-15T10:00:33","date_gmt":"2013-05-15T07:00:33","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=16842"},"modified":"2013-09-04T00:13:01","modified_gmt":"2013-09-03T21:13:01","slug":"spring-security-login","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html","title":{"rendered":"Spring Security Login"},"content":{"rendered":"<h2>1. Introduction<\/h2>\n<p>This article is going to focus on <strong>Login with Spring Security<\/strong>. We\u2019re going to built on top of the simple <a title=\"MVC Tutorial\" href=\"http:\/\/www.baeldung.com\/spring-mvc-tutorial\">previous Spring MVC example<\/a>, as that\u2019s a necessary part of setting up the web application along with the login mechanism.<\/p>\n<h2>2. The Maven Dependencies<\/h2>\n<p>To add Maven dependencies to the project, please see the <a title=\"Maven Spring Security tutorial\" href=\"http:\/\/www.baeldung.com\/spring-security-with-maven\">Spring Security with Maven article<\/a>. Both standard <em>spring-security-web<\/em> and <em>spring-security-config<\/em> will be required.<\/p>\n<h2>3. The <em>web.xml<\/em><\/h2>\n<p>The Spring Security configuration in the <em>web.xml<\/em> is simple \u2013 only an additional filter added to the standard Spring MVC <em>web.xml<\/em>:\u00a0<em><\/em><\/p>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;web-app xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n   xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\" \r\n   xmlns:web=\"http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_3_0.xsd\"\r\n   xsi:schemaLocation=\"\r\n      http:\/\/java.sun.com\/xml\/ns\/javaee \r\n      http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_3_0.xsd\" \r\n   id=\"WebApp_ID\" version=\"3.0\"&gt;\r\n\r\n   &lt;display-name&gt;Spring Secured Application&lt;\/display-name&gt;\r\n\r\n   &lt;!-- Spring MVC --&gt;\r\n   &lt;servlet&gt;\r\n      &lt;servlet-name&gt;mvc&lt;\/servlet-name&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;\/servlet-class&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\r\n\u00a0\u00a0 &lt;\/servlet&gt;\r\n\u00a0\u00a0 &lt;servlet-mapping&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;servlet-name&gt;mvc&lt;\/servlet-name&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;url-pattern&gt;\/&lt;\/url-pattern&gt;\r\n\u00a0\u00a0 &lt;\/servlet-mapping&gt;\r\n\r\n   &lt;context-param&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;param-name&gt;contextClass&lt;\/param-name&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;param-value&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 org.springframework.web.context.support.AnnotationConfigWebApplicationContext\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/param-value&gt;\r\n\u00a0\u00a0 &lt;\/context-param&gt;\r\n\u00a0\u00a0 &lt;context-param&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;param-value&gt;org.baeldung.spring.web.config&lt;\/param-value&gt;\r\n\u00a0\u00a0 &lt;\/context-param&gt;\r\n\u00a0\u00a0 &lt;listener&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;listener-class&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 org.springframework.web.context.ContextLoaderListener\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/listener-class&gt;\r\n\u00a0\u00a0 &lt;\/listener&gt;\r\n\r\n   &lt;!-- Spring Security --&gt;\r\n   &lt;filter&gt;\r\n      &lt;filter-name&gt;springSecurityFilterChain&lt;\/filter-name&gt;\r\n      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;\/filter-class&gt;\r\n   &lt;\/filter&gt;\r\n   &lt;filter-mapping&gt;\r\n      &lt;filter-name&gt;springSecurityFilterChain&lt;\/filter-name&gt;\r\n      &lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;\r\n   &lt;\/filter-mapping&gt;\r\n\r\n&lt;\/web-app&gt;<\/pre>\n<p>The filter \u2013 <em>DelegatingFilterProxy<\/em> \u2013 simply delegates to a Spring managed bean \u2013 the <em>FilterChainProxy<\/em> \u2013 which itself is able to benefit from full Spring bean lifecycle management and such.<\/p>\n<h2>2. The Spring Security configuration<\/h2>\n<p>The Spring configuration is mostly written in Java, but Spring Security configuration doesn\u2019t yet support full Java and still needs to be XML for the most part. There is an ongoing effort to add <a title=\"Spring Security Java based Configuration\" href=\"https:\/\/github.com\/SpringSource\/spring-security-javaconfig\" target=\"_blank\" rel=\"nofollow\">Java based configuration for Spring Security<\/a>, but this is not yet mature.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The overall project is using Java configuration, so the XML configuration file needs to be imported via a Java <em>@Configuration<\/em> class:<\/p>\n<pre class=\" brush:java\">@Configuration\r\n@ImportResource({ \"classpath:webSecurityConfig.xml\" })\r\npublic class SecSecurityConfig {\r\n   public SecSecurityConfig() {\r\n      super();\r\n   }\r\n}<\/pre>\n<p>The Spring Security XML Configuration \u2013 <em>webSecurityConfig.xml<\/em>:<\/p>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;beans:beans xmlns=\"http:\/\/www.springframework.org\/schema\/security\" \r\n  xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n  xmlns:beans=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n  xsi:schemaLocation=\"\r\n      http:\/\/www.springframework.org\/schema\/security \r\n      http:\/\/www.springframework.org\/schema\/security\/spring-security-3.1.xsd\r\n      http:\/\/www.springframework.org\/schema\/beans \r\n      http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.2.xsd\"&gt;\r\n\r\n   &lt;http use-expressions=\"true\"&gt;\r\n      &lt;intercept-url pattern=\"\/login*\" access=\"isAnonymous()\" \/&gt;\r\n      &lt;intercept-url pattern=\"\/**\" access=\"isAuthenticated()\"\/&gt;\r\n\r\n      &lt;form-login \r\n         login-page='\/login.html' \r\n         default-target-url=\"\/homepage.html\" \r\n         authentication-failure-url=\"\/login.html?error=true\" \/&gt;\r\n\r\n      &lt;logout logout-success-url=\"\/login.html\" \/&gt;\r\n\r\n   &lt;\/http&gt;\r\n   &lt;authentication-manager&gt;\r\n      &lt;authentication-provider&gt;\r\n         &lt;user-service&gt;\r\n            &lt;user name=\"user1\" password=\"user1Pass\" authorities=\"ROLE_USER\" \/&gt;\r\n         &lt;\/user-service&gt;\r\n      &lt;\/authentication-provider&gt;\r\n   &lt;\/authentication-manager&gt;\r\n&lt;\/beans:beans&gt;<\/pre>\n<h4>2.1. <em>&lt;intercept-url&gt;<\/em><\/h4>\n<p>We are allowing anonymous access on <em>\/login<\/em> so that users can authenticate. We are also securing everything else.<\/p>\n<p>Note that the <strong>order of the <em>&lt;intercept-url&gt;<\/em><\/strong> element is significant \u2013 the more specific rules need to come first, followed by the more general ones.<\/p>\n<h4>2.2. <em>&lt;form-login&gt;<\/em><\/h4>\n<ul>\n<li><em>login-page<\/em> \u2013 the <strong>custom login page<\/strong><\/li>\n<li><em>default-target-url<\/em> \u2013 the landing page after a successful login<\/li>\n<li><em>authentication-failure-url<\/em> \u2013 the landing page after an unsuccessful login<\/li>\n<\/ul>\n<h4>2.3. <em>&lt;authentication-manager&gt;<\/em><\/h4>\n<p>The Authentication Provider is backed by a simple, in-memory implementation \u2013 <em>InMemoryUserDetailsManager<\/em> specifically\u00a0 \u2013 configured in plain text. This only exists in Spring 3.1 and above and is meant to be used for rapid prototyping when a full persistence mechanism is not yet necessary.<\/p>\n<h2>3. The Login Form<\/h2>\n<p>The login form page is going to be registered with Spring MVC using the straightforward mechanism to <a title=\"Spring MVC View Configuration\" href=\"http:\/\/www.baeldung.com\/spring-mvc-tutorial#configviews\" target=\"_blank\">map views names to URLs<\/a> with no need for an explicit controller in between:<\/p>\n<pre class=\" brush:java\">registry.addViewController(\"\/login.html\");<\/pre>\n<p>This of course corresponds to the <em>login.jsp<\/em>:<\/p>\n<pre class=\" brush:xml\">&lt;html&gt;\r\n&lt;head&gt;&lt;\/head&gt;\r\n&lt;body&gt;\r\n   &lt;h1&gt;Login&lt;\/h1&gt;\r\n   &lt;form name='f' action=\"j_spring_security_check\" method='POST'&gt;\r\n      &lt;table&gt;\r\n         &lt;tr&gt;\r\n            &lt;td&gt;User:&lt;\/td&gt;\r\n            &lt;td&gt;&lt;input type='text' name='j_username' value=''&gt;&lt;\/td&gt;\r\n         &lt;\/tr&gt;\r\n         &lt;tr&gt;\r\n            &lt;td&gt;Password:&lt;\/td&gt;\r\n            &lt;td&gt;&lt;input type='password' name='j_password' \/&gt;&lt;\/td&gt;\r\n         &lt;\/tr&gt;\r\n         &lt;tr&gt;\r\n            &lt;td&gt;&lt;input name=\"submit\" type=\"submit\" value=\"submit\" \/&gt;&lt;\/td&gt;\r\n         &lt;\/tr&gt;\r\n      &lt;\/table&gt;\r\n  &lt;\/form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>The <strong>Spring Login form<\/strong> has the following relevant artifacts:<\/p>\n<ul>\n<li><em>j_spring_security_check<\/em> \u2013 the URL where the form is POSTed to trigger the authentication process<\/li>\n<li><em>j_username<\/em> \u2013 the user name<\/li>\n<li><em>j_password<\/em> \u2013 the password<\/li>\n<\/ul>\n<h2>4. Further Configuring Spring Login<\/h2>\n<p>We briefly discussed a few configurations of the login mechanism when we introduced the Spring Security XML Configuration above \u2013 let\u2019s go into some detail now.<\/p>\n<p>One reason to override most of the defaults in Spring Security is to <strong>hide the fact that the application is secured with Spring Security<\/strong> and minimize the information a potential attacker knows about the application.<\/p>\n<p>Fully configured, the <em>&lt;form-login&gt;<\/em> element looks like this:<\/p>\n<pre class=\" brush:xml\">&lt;form-login \r\n   login-page='\/login.html' \r\n   login-processing-url=\"\/perform_login\" \r\n   default-target-url=\"\/homepage.html\"\r\n   authentication-failure-url=\"\/login.html?error=true\" \r\n   always-use-default-target=\"true\"\/&gt;<\/pre>\n<h4>4.1. The Login page<\/h4>\n<p>The custom login page is configured via the <em>login-page<\/em> attribute o<em>n &lt;form-login&gt;<\/em>:<\/p>\n<pre class=\" brush:xml\">login-page='\/login.html'<\/pre>\n<p>If this is not specified, a default URL is used \u2013 <em>spring_security_login<\/em> \u2013 and Spring Security will generate a very basic Login Form at that URL.<\/p>\n<h4>4.2. The POST URL for Login<\/h4>\n<p>The default URL where the Spring Login will POST to trigger the authentication process is <em>\/j_spring_security_check<\/em>.<\/p>\n<p>This URL can be overridden via the <em>login-processing-url<\/em> attribute on <em>&lt;form-login&gt;<\/em>:<\/p>\n<pre class=\" brush:xml\">login-processing-url=\"\/perform_login\"<\/pre>\n<p>A good reason to override this default URL is to hide the fact that the application is actually secured with Spring Security \u2013 that information should not be available externally.<\/p>\n<h4>4.3. The Landing page on Success<\/h4>\n<p>After a successful Login process, the user is redirected to a page \u2013 which by default is the root of the web application.<\/p>\n<p>This can be overridden via the <em>default-target-url<\/em> attribute on <em>&lt;form-login&gt;<\/em>:<\/p>\n<pre class=\" brush:xml\">default-target-url=\"\/homepage.html\"<\/pre>\n<p>In case the <em>always-use-default-target<\/em> is set to true, then the user is always redirected to this page. If that attribute is set to false, then the user will be redirected to the previous page they wanted to visit before being promoted to authenticate.<\/p>\n<h4>4.4. The Landing page on Failure<\/h4>\n<p>Same as with the Login Page, the Login Failure Page is autogenerated by Spring Security at <em>\/spring_security_login?login_error<\/em> by default.<\/p>\n<p>This can be overridden via the <strong><em>authentication-failure-url<\/em> attribute<\/strong> on <em>&lt;form-login&gt;<\/em>:<\/p>\n<pre class=\" brush:xml\">authentication-failure-url=\"\/login.html?error=true\"<\/pre>\n<h2>5. Conclusion<\/h2>\n<p>In this <strong>Spring Login Example<\/strong> we configured a simple authentication process \u2013 we discussed the Spring Security Login Form, the Security XML Configuration and some of the more advanced customizations available in the namespace.<\/p>\n<p>The implementation of this Spring Login tutorial can be found in <a title=\"Spring Login Tutorial\" href=\"https:\/\/github.com\/eugenp\/tutorials\/tree\/master\/spring-security-mvc-login#readme\" target=\"_blank\" rel=\"nofollow\">the github project<\/a> \u2013 this is an Eclipse based project, so it should be easy to import and run as it is.<\/p>\n<p>When the project runs locally, the sample html can be accessed at:<\/p>\n<ul>\n<li><a title=\"Login for Spring Security\" href=\"http:\/\/localhost:8080\/spring-security-login\/login.html\" target=\"_blank\" rel=\"nofollow\">http:\/\/localhost:8080\/spring-security-login\/login.html<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/www.baeldung.com\/spring-security-login\">Spring Security Form Login<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Eugen Paraschiv at the <a href=\"http:\/\/www.baeldung.com\/\">baeldung<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction This article is going to focus on Login with Spring Security. We\u2019re going to built on top of the simple previous Spring MVC example, as that\u2019s a necessary part of setting up the web application along with the login mechanism. 2. The Maven Dependencies To add Maven dependencies to the project, please see &hellip;<\/p>\n","protected":false},"author":104,"featured_media":242,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30,125],"class_list":["post-16842","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring","tag-spring-security"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Security Form Login<\/title>\n<meta name=\"description\" content=\"1. Introduction This article is going to focus on Login with Spring Security. We\u2019re going to built on top of the simple previous Spring MVC example, as\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Security Form Login\" \/>\n<meta property=\"og:description\" content=\"1. Introduction This article is going to focus on Login with Spring Security. We\u2019re going to built on top of the simple previous Spring MVC example, as\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-15T07:00:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-09-03T21:13:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-security-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Eugen Paraschiv\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/baeldung\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eugen Paraschiv\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html\"},\"author\":{\"name\":\"Eugen Paraschiv\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7a8ad27f4bb34bb3664fda07d3142bc4\"},\"headline\":\"Spring Security Login\",\"datePublished\":\"2013-05-15T07:00:33+00:00\",\"dateModified\":\"2013-09-03T21:13:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html\"},\"wordCount\":798,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-security-logo.jpg\",\"keywords\":[\"Spring\",\"Spring Security\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html\",\"name\":\"Spring Security Form Login\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-security-logo.jpg\",\"datePublished\":\"2013-05-15T07:00:33+00:00\",\"dateModified\":\"2013-09-03T21:13:01+00:00\",\"description\":\"1. Introduction This article is going to focus on Login with Spring Security. We\u2019re going to built on top of the simple previous Spring MVC example, as\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-security-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-security-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-security-login.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Security Login\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7a8ad27f4bb34bb3664fda07d3142bc4\",\"name\":\"Eugen Paraschiv\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1e55876feb753ccc6de08d413df2c915e5704dd901010340c1499a7572f8d7a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1e55876feb753ccc6de08d413df2c915e5704dd901010340c1499a7572f8d7a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1e55876feb753ccc6de08d413df2c915e5704dd901010340c1499a7572f8d7a?s=96&d=mm&r=g\",\"caption\":\"Eugen Paraschiv\"},\"sameAs\":[\"http:\\\/\\\/www.baeldung.com\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/eugenparaschiv\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/baeldung\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Eugen-Paraschiv\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Security Form Login","description":"1. Introduction This article is going to focus on Login with Spring Security. We\u2019re going to built on top of the simple previous Spring MVC example, as","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html","og_locale":"en_US","og_type":"article","og_title":"Spring Security Form Login","og_description":"1. Introduction This article is going to focus on Login with Spring Security. We\u2019re going to built on top of the simple previous Spring MVC example, as","og_url":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-05-15T07:00:33+00:00","article_modified_time":"2013-09-03T21:13:01+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-security-logo.jpg","type":"image\/jpeg"}],"author":"Eugen Paraschiv","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/baeldung","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Eugen Paraschiv","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html"},"author":{"name":"Eugen Paraschiv","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7a8ad27f4bb34bb3664fda07d3142bc4"},"headline":"Spring Security Login","datePublished":"2013-05-15T07:00:33+00:00","dateModified":"2013-09-03T21:13:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html"},"wordCount":798,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-security-logo.jpg","keywords":["Spring","Spring Security"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html","url":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html","name":"Spring Security Form Login","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-security-logo.jpg","datePublished":"2013-05-15T07:00:33+00:00","dateModified":"2013-09-03T21:13:01+00:00","description":"1. Introduction This article is going to focus on Login with Spring Security. We\u2019re going to built on top of the simple previous Spring MVC example, as","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-security-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-security-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-security-login.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Security Login"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7a8ad27f4bb34bb3664fda07d3142bc4","name":"Eugen Paraschiv","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d1e55876feb753ccc6de08d413df2c915e5704dd901010340c1499a7572f8d7a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d1e55876feb753ccc6de08d413df2c915e5704dd901010340c1499a7572f8d7a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d1e55876feb753ccc6de08d413df2c915e5704dd901010340c1499a7572f8d7a?s=96&d=mm&r=g","caption":"Eugen Paraschiv"},"sameAs":["http:\/\/www.baeldung.com\/","http:\/\/www.linkedin.com\/in\/eugenparaschiv","https:\/\/x.com\/http:\/\/twitter.com\/baeldung"],"url":"https:\/\/www.javacodegeeks.com\/author\/Eugen-Paraschiv"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/16842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/104"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=16842"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/16842\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/242"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=16842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=16842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=16842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}