{"id":17441,"date":"2021-07-28T18:18:09","date_gmt":"2021-07-28T11:18:09","guid":{"rendered":"https:\/\/huongdanjava.com\/?p=17441"},"modified":"2022-04-01T06:38:08","modified_gmt":"2022-03-31T23:38:08","slug":"multiple-login-pages-with-spring-security","status":"publish","type":"post","link":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html","title":{"rendered":"Multiple login pages with Spring Security"},"content":{"rendered":"<p>In real projects, you may encounter some cases where the application needs to use two different login methods depending on the user&#8217;s role, for example, there are applications that will need normal users to login using tokens or QR code, and admin login using username and password. How to implement multiple login pages using Spring Security? I will guide you in this tutorial.<\/p>\n<h3>Example application<\/h3>\n<p>First, I will create a new Spring Boot project with Spring Security Starter, Spring Web Starter, Thymeleaf Starter:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-17443 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/multiple-login-page-with-spring-security-1.png\" alt=\"Multiple login page with Spring Security\" width=\"700\" height=\"848\" \/><\/p>\n<p>and WebJars with Bootstrap dependency for example as follows:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;dependency&gt;\r\n    &lt;groupId&gt;org.webjars&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;webjars-locator-core&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;org.webjars&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;bootstrap&lt;\/artifactId&gt;\r\n    &lt;version&gt;5.0.2&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>Result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-17444 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/multiple-login-page-with-spring-security-2.png\" alt=\"Multiple login page with Spring Security\" width=\"700\" height=\"541\" \/><\/p>\n<p>To demonstrate the need we are trying to solve, I will create a controller to expose 2 pages, one only for the user with the USER role and the other only for the user with the ADMIN role. As follows:<\/p>\n<pre class=\"lang:java decode:true \">package com.huongdanjava.springsecurity;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.GetMapping;\r\n\r\n@Controller\r\npublic class ApplicationController {\r\n\r\n    @GetMapping(\"\/user\/view\")\r\n    public String userView() {\r\n        return \"user\";\r\n    }\r\n\r\n    @GetMapping(\"\/admin\/view\")\r\n    public String adminView() {\r\n        return \"admin\";\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>The Thymeleaf template for these pages is as follows:<\/p>\n<p>admin.html:<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\" xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"utf-8\"&gt;\r\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"&gt;\r\n&lt;meta name=\"description\" content=\"\"&gt;\r\n&lt;meta name=\"author\" content=\"\"&gt;\r\n&lt;title&gt;Spring Security Example&lt;\/title&gt;\r\n&lt;link href=\"\/webjars\/bootstrap\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\t&lt;div class=\"container\"&gt;\r\n\t\t&lt;h2 class=\"form-signin-heading\"&gt;Hello Admin&lt;\/h2&gt;\r\n\t&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>user.html:<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\" xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"utf-8\"&gt;\r\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"&gt;\r\n&lt;meta name=\"description\" content=\"\"&gt;\r\n&lt;meta name=\"author\" content=\"\"&gt;\r\n&lt;title&gt;Spring Security Example&lt;\/title&gt;\r\n&lt;link href=\"\/webjars\/bootstrap\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\t&lt;div class=\"container\"&gt;\r\n\t\t&lt;h2 class=\"form-signin-heading\"&gt;Hello User&lt;\/h2&gt;\r\n\t&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>Now, if you run the application and request to these two pages, the default login page of Spring Security will always be displayed.<\/p>\n<p>I will use Spring Security&#8217;s default login page for user &#8220;admin&#8221; with username and password, and for normal user &#8220;user&#8221;, I will use a custom login page with username and password, similar to what I did in <a href=\"https:\/\/huongdanjava.com\/custom-login-page-using-bootstrap-and-thymeleaf-in-spring-security.html\" target=\"_blank\" rel=\"noopener noreferrer\">Custom login page using Bootstrap and Thymeleaf in Spring Security<\/a>.<\/p>\n<p>The login-user.html page code for normal users to log in is as follows:<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\" xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"utf-8\"&gt;\r\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"&gt;\r\n&lt;meta name=\"description\" content=\"\"&gt;\r\n&lt;meta name=\"author\" content=\"\"&gt;\r\n&lt;title&gt;Spring Security Example&lt;\/title&gt;\r\n&lt;link href=\"\/webjars\/bootstrap\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\t&lt;div class=\"container\"&gt;\r\n\t\t&lt;h2 class=\"form-signin-heading\"&gt;Welcome to Huong Dan Java, please login&lt;\/h2&gt;\r\n\t\t&lt;div th:if=\"${param.error}\" class=\"alert alert-danger\"&gt;    \r\n        \tInvalid username and password.\r\n        &lt;\/div&gt;\r\n        &lt;div th:if=\"${param.logout}\" class=\"alert alert-success\"&gt; \r\n            You have been logged out.\r\n        &lt;\/div&gt;\r\n\t\t&lt;form class=\"form-signin\" method=\"POST\" th:action=\"@{\/login}\"&gt;\r\n\t\t\t&lt;p&gt;\r\n\t\t\t\t&lt;label for=\"username\" class=\"sr-only\"&gt;Username&lt;\/label&gt; \r\n\t\t\t\t&lt;input type=\"text\" id=\"username\" name=\"username\" class=\"form-control\"\r\n\t\t\t\t\tplaceholder=\"Username\" required autofocus&gt;\r\n\t\t\t&lt;\/p&gt;\r\n\t\t\t&lt;p&gt;\r\n\t\t\t\t&lt;label for=\"password\" class=\"sr-only\"&gt;Password&lt;\/label&gt; \r\n\t\t\t\t&lt;input type=\"password\" id=\"password\" name=\"password\" class=\"form-control\"\r\n\t\t\t\t\tplaceholder=\"Password\" required&gt;\r\n\t\t\t&lt;\/p&gt;\r\n\t\t\t&lt;button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\"&gt;Login&lt;\/button&gt;\r\n\t\t&lt;\/form&gt;\r\n\t&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>Expose this login page in the ApplicationController class as follows:<\/p>\n<pre class=\"lang:java decode:true \">@GetMapping(\"\/user-login\")\r\npublic String userLoginView() {\r\n    return \"login-user\";\r\n}<\/pre>\n<p>Now I will configure Spring Security for requests to these 2 sites.<\/p>\n<h3>Spring Security Configuration<\/h3>\n<p>First, I will configure information about the user who will log in to the example application.<\/p>\n<p>As I said above, we will have 2 users, &#8220;user&#8221; and &#8220;admin&#8221; with roles &#8220;USER&#8221; and &#8220;admin&#8221; respectively ADMIN&#8221;. Both of these users will use the same source for authentication, which means they are stored in the same place, in this tutorial, we will use the source as in memory.<\/p>\n<p>I will create a bean for the UserDetailsService object containing the information of these two users as follows:<\/p>\n<pre class=\"lang:java decode:true\">package com.huongdanjava.springsecurity;\r\n\r\nimport org.springframework.boot.SpringApplication;\r\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.security.core.userdetails.User;\r\nimport org.springframework.security.core.userdetails.UserDetailsService;\r\nimport org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;\r\nimport org.springframework.security.crypto.password.PasswordEncoder;\r\nimport org.springframework.security.provisioning.InMemoryUserDetailsManager;\r\n\r\n@SpringBootApplication\r\npublic class SpringSecurityMultipleLoginApplication {\r\n\r\n    public static void main(String[] args) {\r\n        SpringApplication.run(SpringSecurityMultipleLoginApplication.class, args);\r\n    }\r\n\r\n    @Bean\r\n    public UserDetailsService userDetailsService() throws Exception {\r\n        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();\r\n        manager.createUser(User\r\n            .withUsername(\"user\")\r\n            .password(encoder().encode(\"user\"))\r\n            .roles(\"USER\")\r\n            .build());\r\n\r\n        manager.createUser(User\r\n            .withUsername(\"admin\")\r\n            .password(encoder().encode(\"admin\"))\r\n            .roles(\"ADMIN\")\r\n            .build());\r\n\r\n        return manager;\r\n    }\r\n\r\n    @Bean\r\n    public static PasswordEncoder encoder() {\r\n        return new BCryptPasswordEncoder();\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Next, we will configure Spring Security.<\/p>\n<p>Here, because we need to handle the request for the user with the role &#8220;USER&#8221;, we will display the custom login page and the user with the &#8220;ADMIN&#8221; role will display the default login page of Spring Security, so I will define multiple class extends abstract class WebSecurityConfigurerAdapter with the following order:<\/p>\n<pre class=\"lang:java decode:true\">package com.huongdanjava.springsecurity;\r\n\r\nimport org.springframework.context.annotation.Configuration;\r\nimport org.springframework.core.annotation.Order;\r\nimport org.springframework.security.config.Customizer;\r\nimport org.springframework.security.config.annotation.web.builders.HttpSecurity;\r\nimport org.springframework.security.config.annotation.web.builders.WebSecurity;\r\nimport org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;\r\nimport org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;\r\n\r\n@EnableWebSecurity\r\npublic class SpringSecurityConfiguration {\r\n\r\n    @Configuration\r\n    @Order(1)\r\n    public class UserSpringSecurityConfiguration extends WebSecurityConfigurerAdapter {\r\n\r\n        @Override\r\n        protected void configure(HttpSecurity http) throws Exception {\r\n            \/\/ @formatter:off\r\n            http.antMatcher(\"\/user\/**\")\r\n                    .authorizeRequests()\r\n                        .anyRequest().hasRole(\"USER\")\r\n                        .and()\r\n                    .formLogin()\r\n                        .loginPage(\"\/user-login\")\r\n                        .failureUrl(\"\/user-login?error\")\r\n                        .permitAll();\r\n            \/\/ @formatter:on\r\n        }\r\n    }\r\n\r\n    @Configuration\r\n    public class AdminSpringSecurityConfiguration extends WebSecurityConfigurerAdapter {\r\n\r\n        @Override\r\n        protected void configure(HttpSecurity http) throws Exception {\r\n            \/\/ @formatter:off\r\n            http\r\n                .authorizeRequests()\r\n                    .antMatchers(\"\/user-login\/**\").permitAll()\r\n                    .anyRequest().hasRole(\"ADMIN\")\r\n                    .and()\r\n                .formLogin(Customizer.withDefaults());\r\n            \/\/ @formatter:on\r\n        }\r\n\r\n        @Override\r\n        public void configure(WebSecurity web) throws Exception {\r\n            web.ignoring().antMatchers(\"\/webjars\/**\");\r\n        }\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Here, I am declaring to handle the request of a normal user using the UserSpringSecurityConfiguration class and the admin user does the rest. I just declare the @Order annotation for the UserSpringSecurityConfiguration class so that it is called first to handle any request, if the antMatcher() condition is not met for it to handle that request, the AdminSpringSecurityConfiguration class will handle the request.<\/p>\n<p>As you can see, for requests that start with &#8220;\/user&#8221;, if the user does not have the &#8220;USER&#8221; role, I configure our example application to redirect to the &#8220;\/user-login&#8221; page so that the user can log in, now the AdminSpringSecurityConfiguration class will handle this &#8220;\/user-login&#8221; request. In the AdminSpringSecurityConfiguration class, I have configured for the request that starts with &#8220;\/user-login&#8221;, we will permitAll(). The &#8220;\/user-login&#8221; page will now be displayed. If the login is successful and the user has the &#8220;USER&#8221; role, our application will automatically redirect to the page starting with &#8220;\/user&#8221; that we requested.<\/p>\n<p>Run the application and request to <a href=\"http:\/\/localhost:8080\/user\/view\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/localhost:8080\/user\/view<\/a>, you will see the custom login page displayed as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-17445 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/multiple-login-page-with-spring-security-3.png\" alt=\"Multiple login page with Spring Security\" width=\"700\" height=\"378\" \/><\/p>\n<p>Log in with user &#8220;user&#8221; and password as &#8220;user&#8221;, you will see the following results:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-17446 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/multiple-login-page-with-spring-security-4.png\" alt=\"Multiple login page with Spring Security\" width=\"700\" height=\"446\" \/><\/p>\n<p>And if you request to <a href=\"http:\/\/localhost:8080\/admin\/view\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/localhost:8080\/admin\/view<\/a>, you will see Spring Security&#8217;s default login page displayed. Login with user &#8220;admin&#8221; and password &#8220;admin&#8221;, you will see the following results:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-17447 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/multiple-login-page-with-spring-security-5.png\" alt=\"Multiple login page with Spring Security\" width=\"700\" height=\"446\" \/><\/p>\n<p>In the AdminSpringSecurityConfiguration class, I have configured for the remaining requests, except for the &#8220;\/user\/**&#8221; request, the user must have the role of &#8220;ADMIN&#8221;.<\/p>\n<p>Remember that, to configure for a specific request URL, we will use the antMatcher() method of the HttpSecurity object with the value starting with the request URL we need. For the remaining requests, do not declare the @Order annotation with the configuration class, so that it is always in the highest order.<\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-right kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;right&quot;,&quot;id&quot;:&quot;17441&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;4&quot;,&quot;greet&quot;:&quot;&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;Multiple login pages with Spring Security&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\"><\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>In real projects, you may encounter some cases where the application needs to use two different login methods depending on the user&#8217;s role, for example, there are applications that will need normal users to login using tokens or QR code, and admin login using username&hellip; <a href=\"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":14897,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1891],"tags":[],"class_list":["post-17441","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-security","clearfix"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Multiple login pages with Spring Security - Huong Dan Java<\/title>\n<meta name=\"description\" content=\"In this tutorial, I will guide you all on how to implement multiple login pages with Spring Security.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Multiple login pages with Spring Security - Huong Dan Java\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, I will guide you all on how to implement multiple login pages with Spring Security.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html\" \/>\n<meta property=\"og:site_name\" content=\"Huong Dan Java\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/nhkhanh2406\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/nhkhanh2406\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-28T11:18:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-31T23:38:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/08\/spring-security.png\" \/>\n\t<meta property=\"og:image:width\" content=\"200\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Khanh Nguyen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/KhanhNguyenJ\" \/>\n<meta name=\"twitter:site\" content=\"@KhanhNguyenJ\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Khanh Nguyen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html\"},\"author\":{\"name\":\"Khanh Nguyen\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\"},\"headline\":\"Multiple login pages with Spring Security\",\"datePublished\":\"2021-07-28T11:18:09+00:00\",\"dateModified\":\"2022-03-31T23:38:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html\"},\"wordCount\":701,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\"},\"image\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/spring-security.png\",\"articleSection\":[\"Spring Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html\",\"name\":\"Multiple login pages with Spring Security - Huong Dan Java\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/spring-security.png\",\"datePublished\":\"2021-07-28T11:18:09+00:00\",\"dateModified\":\"2022-03-31T23:38:08+00:00\",\"description\":\"In this tutorial, I will guide you all on how to implement multiple login pages with Spring Security.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#primaryimage\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/spring-security.png\",\"contentUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/spring-security.png\",\"width\":200,\"height\":200},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/multiple-login-pages-with-spring-security.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/huongdanjava.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Multiple login pages with Spring Security\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#website\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/\",\"name\":\"Huong Dan Java\",\"description\":\"Java development tutorials\",\"publisher\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/huongdanjava.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\",\"name\":\"Khanh Nguyen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\",\"contentUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\",\"width\":1267,\"height\":1517,\"caption\":\"Khanh Nguyen\"},\"logo\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\"},\"description\":\"I love Java and everything related to Java.\",\"sameAs\":[\"https:\\\/\\\/huongdanjava.com\",\"https:\\\/\\\/www.facebook.com\\\/nhkhanh2406\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/KhanhNguyenJ\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Multiple login pages with Spring Security - Huong Dan Java","description":"In this tutorial, I will guide you all on how to implement multiple login pages with Spring Security.","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:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html","og_locale":"en_US","og_type":"article","og_title":"Multiple login pages with Spring Security - Huong Dan Java","og_description":"In this tutorial, I will guide you all on how to implement multiple login pages with Spring Security.","og_url":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html","og_site_name":"Huong Dan Java","article_publisher":"https:\/\/www.facebook.com\/nhkhanh2406","article_author":"https:\/\/www.facebook.com\/nhkhanh2406","article_published_time":"2021-07-28T11:18:09+00:00","article_modified_time":"2022-03-31T23:38:08+00:00","og_image":[{"width":200,"height":200,"url":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/08\/spring-security.png","type":"image\/png"}],"author":"Khanh Nguyen","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/KhanhNguyenJ","twitter_site":"@KhanhNguyenJ","twitter_misc":{"Written by":"Khanh Nguyen","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#article","isPartOf":{"@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html"},"author":{"name":"Khanh Nguyen","@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d"},"headline":"Multiple login pages with Spring Security","datePublished":"2021-07-28T11:18:09+00:00","dateModified":"2022-03-31T23:38:08+00:00","mainEntityOfPage":{"@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html"},"wordCount":701,"commentCount":0,"publisher":{"@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d"},"image":{"@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#primaryimage"},"thumbnailUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/08\/spring-security.png","articleSection":["Spring Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html","url":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html","name":"Multiple login pages with Spring Security - Huong Dan Java","isPartOf":{"@id":"https:\/\/huongdanjava.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#primaryimage"},"image":{"@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#primaryimage"},"thumbnailUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/08\/spring-security.png","datePublished":"2021-07-28T11:18:09+00:00","dateModified":"2022-03-31T23:38:08+00:00","description":"In this tutorial, I will guide you all on how to implement multiple login pages with Spring Security.","breadcrumb":{"@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#primaryimage","url":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/08\/spring-security.png","contentUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/08\/spring-security.png","width":200,"height":200},{"@type":"BreadcrumbList","@id":"https:\/\/huongdanjava.com\/multiple-login-pages-with-spring-security.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/huongdanjava.com\/"},{"@type":"ListItem","position":2,"name":"Multiple login pages with Spring Security"}]},{"@type":"WebSite","@id":"https:\/\/huongdanjava.com\/#website","url":"https:\/\/huongdanjava.com\/","name":"Huong Dan Java","description":"Java development tutorials","publisher":{"@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/huongdanjava.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d","name":"Khanh Nguyen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg","url":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg","contentUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg","width":1267,"height":1517,"caption":"Khanh Nguyen"},"logo":{"@id":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg"},"description":"I love Java and everything related to Java.","sameAs":["https:\/\/huongdanjava.com","https:\/\/www.facebook.com\/nhkhanh2406","https:\/\/x.com\/https:\/\/twitter.com\/KhanhNguyenJ"]}]}},"_links":{"self":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts\/17441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/comments?post=17441"}],"version-history":[{"count":6,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts\/17441\/revisions"}],"predecessor-version":[{"id":19797,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts\/17441\/revisions\/19797"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/media\/14897"}],"wp:attachment":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/media?parent=17441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/categories?post=17441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/tags?post=17441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}