{"id":9554,"date":"2013-03-08T19:00:26","date_gmt":"2013-03-08T17:00:26","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=9554"},"modified":"2013-03-08T06:32:50","modified_gmt":"2013-03-08T04:32:50","slug":"add-rememberme-authentication-with-spring-security","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html","title":{"rendered":"Add RememberMe Authentication With Spring Security"},"content":{"rendered":"<p>I mentioned in my post <a href=\"http:\/\/www.jiwhiz.com\/post\/2013\/1\/Add_Social_Login_to_Jiwhiz_Blog\"> Add Social Login to Jiwhiz Blog<\/a> that the RememberMe function was not working with Spring Social Security. Well, it is because the application is not authenticating the user by username and password now, and is totally depending on social websites (like Google, Facebook and Twitter) to do the job. The default Spring Security configuration cannot handle this situation. <a href=\"http:\/\/www.springsource.org\/spring-security\">Spring Security<\/a> might be the most complicated software among all <a href=\"http:\/\/www.springsource.org\/projects\">Spring Portfolio projects<\/a>. There are about 10 filters needing to be set up correctly to get a very simple Web application to work with security. To simplify application development, Spring Security provides <a href=\"http:\/\/static.springsource.org\/spring-security\/site\/docs\/3.1.x\/reference\/ns-config.html\"> namespace configuration<\/a> since version 2.0 to automatically set up all the necessary components together, so developers don&#8217;t need to figure out the details. It works very well for most of the Web applications, unless your application is different from a traditional one.<\/p>\n<p>After I changed my website login process from username password authentication to <a href=\"http:\/\/www.springsource.org\/spring-social\">Spring Social Security<\/a> without a password, the old configuration for remember-me didn&#8217;t work anymore. The Spring Security Reference document has very few explanations about <a href=\"http:\/\/static.springsource.org\/spring-security\/site\/docs\/3.1.x\/reference\/remember-me.html\"> Remember-Me Authentication<\/a>, so I bought the book <a href=\"http:\/\/www.packtpub.com\/spring-security-3-1\/book\">Spring Security 3.1<\/a> written by Rob Winch, the project lead of Spring Security. The book has an entire chapter talking about Remember-Me Services, and it helped me a lot to understand how remember-me works in Spring Security. After reading the book, I feel it is much easier to read the Spring Security source code, and reading the source code is always enjoyable.<\/p>\n<p>Since I&#8217;m not storing passwords for users&#8217; accounts, the default <a href=\"http:\/\/static.springsource.org\/spring-security\/site\/docs\/3.1.x\/apidocs\/org\/springframework\/security\/web\/authentication\/rememberme\/TokenBasedRememberMeServices.html\">TokenBasedRememberMeServices<\/a> cannot work with my application, and I don&#8217;t want to create my own RememberMeServices &#8211; too much work. Fortunately, there is another <a href=\"http:\/\/static.springsource.org\/spring-security\/site\/docs\/3.1.x\/reference\/remember-me.html#remember-me-persistent-token\"> Persistent Token Approach<\/a>, that is to store tokens into the database and compare tokens inside cookies. All I need is to customize <a href=\"http:\/\/static.springsource.org\/spring-security\/site\/docs\/3.1.x\/apidocs\/org\/springframework\/security\/web\/authentication\/rememberme\/PersistentTokenBasedRememberMeServices.html\">PersistentTokenBasedRememberMeServices<\/a> in my application with <a href=\"http:\/\/static.springsource.org\/spring-security\/site\/docs\/3.1.x\/apidocs\/org\/springframework\/security\/web\/authentication\/rememberme\/PersistentTokenRepository.html\">PersistentTokenRepository<\/a> to store the tokens. Spring Security provides a JDBC implementation of PersistentTokenRepository, and I found it is trivial to write my own implementation for MongoDB after reading the source code.<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 first step is to store data of <a href=\"http:\/\/static.springsource.org\/spring-security\/site\/docs\/3.1.x\/apidocs\/org\/springframework\/security\/web\/authentication\/rememberme\/PersistentRememberMeToken.html\"> PersistentRememberMeToken<\/a> to MongoDB. I need to add a domain entity class for it:<\/p>\n<pre class=\" brush:java\">@Document(collection = 'RememberMeToken')\r\npublic class RememberMeToken extends BaseEntity{\r\n\r\n    private String username;\r\n\r\n    @Indexed\r\n    private String series;\r\n\r\n    private String tokenValue;\r\n\r\n    private Date date;\r\n\r\n... \/\/ getter\/setter omitted\r\n\r\n    public RememberMeToken(){\r\n\r\n    }\r\n\r\n    public RememberMeToken(PersistentRememberMeToken token){\r\n        this.series = token.getSeries();\r\n        this.username = token.getUsername();\r\n        this.tokenValue = token.getTokenValue();\r\n        this.date = token.getDate();\r\n    }\r\n\r\n}<\/pre>\n<p>Next, use <a href=\"http:\/\/www.springsource.org\/spring-data\">Spring Data<\/a> to add a repository for the entity:<\/p>\n<pre class=\" brush:java\">public interface RememberMeTokenRepository extends MongoRepository&lt;RememberMeToken, String&gt;{\r\n    RememberMeToken findBySeries(String series);\r\n    List&lt;RememberMeToken&gt; findByUsername(String username);\r\n}<\/pre>\n<p>Then the only relatively heavy coding is to implement PersistentTokenRepository for MongoDB:<\/p>\n<pre class=\" brush:java\">public class MongoPersistentTokenRepositoryImpl implements PersistentTokenRepository {\r\n\r\n    private final RememberMeTokenRepository rememberMeTokenRepository;\r\n\r\n    public MongoPersistentTokenRepositoryImpl(RememberMeTokenRepository rememberMeTokenRepository){\r\n        this.rememberMeTokenRepository = rememberMeTokenRepository;\r\n    }\r\n\r\n    @Override\r\n    public void createNewToken(PersistentRememberMeToken token) {\r\n        RememberMeToken newToken = new RememberMeToken(token);\r\n        this.rememberMeTokenRepository.save(newToken);\r\n    }\r\n\r\n    @Override\r\n    public void updateToken(String series, String tokenValue, Date lastUsed) {\r\n        RememberMeToken token = this.rememberMeTokenRepository.findBySeries(series);\r\n        if (token != null){\r\n            token.setTokenValue(tokenValue);\r\n            token.setDate(lastUsed);\r\n            this.rememberMeTokenRepository.save(token);\r\n        }\r\n\r\n    }\r\n\r\n    @Override\r\n    public PersistentRememberMeToken getTokenForSeries(String seriesId) {\r\n        RememberMeToken token = this.rememberMeTokenRepository.findBySeries(seriesId);\r\n        return new PersistentRememberMeToken(token.getUsername(), token.getSeries(), token.getTokenValue(), token.getDate());\r\n    }\r\n\r\n    @Override\r\n    public void removeUserTokens(String username) {\r\n        List&lt;RememberMeToken&gt; tokens = this.rememberMeTokenRepository.findByUsername(username);\r\n        this.rememberMeTokenRepository.delete(tokens);\r\n    }\r\n}<\/pre>\n<p>The rest of the work is all configuration. I need to wire them together in Java config class:<\/p>\n<pre class=\" brush:java\">@Configuration\r\npublic class SocialAndSecurityConfig {\r\n    @Inject\r\n    private Environment environment;\r\n\r\n    @Inject\r\n    private AccountService accountService;\r\n\r\n    @Inject\r\n    private AuthenticationManager authenticationManager;\r\n\r\n    @Inject\r\n    private RememberMeTokenRepository rememberMeTokenRepository;\r\n\r\n...\r\n\r\n    @Bean\r\n    public RememberMeServices rememberMeServices(){\r\n        PersistentTokenBasedRememberMeServices rememberMeServices = new PersistentTokenBasedRememberMeServices(\r\n                        environment.getProperty('application.key'), accountService, persistentTokenRepository());\r\n        rememberMeServices.setAlwaysRemember(true);\r\n        return rememberMeServices;\r\n    }\r\n\r\n    @Bean \r\n    public RememberMeAuthenticationProvider rememberMeAuthenticationProvider(){\r\n        RememberMeAuthenticationProvider rememberMeAuthenticationProvider = \r\n                        new RememberMeAuthenticationProvider(environment.getProperty('application.key'));\r\n        return rememberMeAuthenticationProvider; \r\n    }\r\n\r\n    @Bean \r\n    public PersistentTokenRepository persistentTokenRepository() {\r\n        return new MongoPersistentTokenRepositoryImpl(rememberMeTokenRepository);\r\n    }\r\n}<\/pre>\n<p>The last step is to add the remember-me service to security xml config file, which is the last piece of xml config and we cannot eliminate it now. (Update: a new project <a href=\"https:\/\/github.com\/SpringSource\/spring-security-javaconfig\/\">Spring Security Java Config<\/a> will replace xml configuration with Java config in Spring Security.)<\/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:beans='http:\/\/www.springframework.org\/schema\/beans'\r\n    xmlns:xsi='http:\/\/www.w3.org\/2001\/XMLSchema-instance'\r\n    xsi:schemaLocation='\r\n        http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.1.xsd\r\n        http:\/\/www.springframework.org\/schema\/security http:\/\/www.springframework.org\/schema\/security\/spring-security-3.1.xsd'&gt;\r\n\r\n    &lt;http use-expressions='true' entry-point-ref='socialAuthenticationEntryPoint'&gt;\r\n        &lt;custom-filter position='PRE_AUTH_FILTER' ref='socialAuthenticationFilter' \/&gt;\r\n        &lt;logout logout-url='\/signout' delete-cookies='JSESSIONID' \/&gt;\r\n        &lt;remember-me services-ref='rememberMeServices' \/&gt;\r\n        &lt;!-- Configure these elements to secure URIs in your application --&gt;\r\n        &lt;intercept-url pattern='\/favicon.ico' access='permitAll' \/&gt;\r\n        &lt;intercept-url pattern='\/robots.txt' access='permitAll' \/&gt;\r\n        &lt;intercept-url pattern='\/resources\/**' access='permitAll' \/&gt;\r\n        &lt;intercept-url pattern='\/signin' access='permitAll'\r\n            requires-channel='#{environment['application.secureChannel']}' \/&gt;\r\n        &lt;intercept-url pattern='\/signin\/*' access='permitAll'\r\n            requires-channel='#{environment['application.secureChannel']}' \/&gt;\r\n        &lt;intercept-url pattern='\/presentation\/**' access='hasRole('ROLE_USER')'\r\n            requires-channel='#{environment['application.secureChannel']}' \/&gt;\r\n        &lt;intercept-url pattern='\/myAccount\/**' access='hasRole('ROLE_USER')'\r\n            requires-channel='#{environment['application.secureChannel']}' \/&gt;\r\n        &lt;intercept-url pattern='\/myPost\/**' access='hasRole('ROLE_AUTHOR')'\r\n            requires-channel='#{environment['application.secureChannel']}' \/&gt;\r\n        &lt;intercept-url pattern='\/admin\/**' access='hasRole('ROLE_ADMIN')'\r\n            requires-channel='#{environment['application.secureChannel']}' \/&gt;\r\n        &lt;intercept-url pattern='\/**' access='permitAll' \/&gt;\r\n\r\n    &lt;\/http&gt;\r\n\r\n    &lt;authentication-manager alias='authenticationManager'&gt;\r\n        &lt;authentication-provider ref='socialAuthenticationProvider' \/&gt;\r\n        &lt;authentication-provider ref='rememberMeAuthenticationProvider' \/&gt;\r\n    &lt;\/authentication-manager&gt;\r\n\r\n&lt;\/beans:beans&gt;<\/pre>\n<p>That&#8217;s all for adding Remember-Me Authentication to my blog application. Now you can login through Google\/Facebook\/Twitter to my website, and the website will consistently remember you for the next two weeks.<br \/>\n&nbsp;<\/p>\n<p><b><i>Reference: <\/i><\/b><a href=\"http:\/\/www.jiwhiz.com\/post\/2013\/2\/Add_RememberMe_Authentication_With_Spring_Security\">Add RememberMe Authentication With Spring Security<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Yuan Ji at the <a href=\"http:\/\/www.jiwhiz.com\/\">Jiwhiz<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I mentioned in my post Add Social Login to Jiwhiz Blog that the RememberMe function was not working with Spring Social Security. Well, it is because the application is not authenticating the user by username and password now, and is totally depending on social websites (like Google, Facebook and Twitter) to do the job. The &hellip;<\/p>\n","protected":false},"author":364,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[297,30,125],"class_list":["post-9554","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-security","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>Add RememberMe Authentication With Spring Security<\/title>\n<meta name=\"description\" content=\"I mentioned in my post Add Social Login to Jiwhiz Blog that the RememberMe function was not working with Spring Social Security. Well, it is because the\" \/>\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\/03\/add-rememberme-authentication-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=\"Add RememberMe Authentication With Spring Security\" \/>\n<meta property=\"og:description\" content=\"I mentioned in my post Add Social Login to Jiwhiz Blog that the RememberMe function was not working with Spring Social Security. Well, it is because the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.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-03-08T17:00:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-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=\"Yuan Ji\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/jiwhiz\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yuan Ji\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html\"},\"author\":{\"name\":\"Yuan Ji\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ab7cf96563ce3fe234bd3912c2580820\"},\"headline\":\"Add RememberMe Authentication With Spring Security\",\"datePublished\":\"2013-03-08T17:00:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html\"},\"wordCount\":510,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Security\",\"Spring\",\"Spring Security\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html\",\"name\":\"Add RememberMe Authentication With Spring Security\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2013-03-08T17:00:26+00:00\",\"description\":\"I mentioned in my post Add Social Login to Jiwhiz Blog that the RememberMe function was not working with Spring Social Security. Well, it is because the\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/add-rememberme-authentication-with-spring-security.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\":\"Add RememberMe Authentication With Spring Security\"}]},{\"@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\\\/ab7cf96563ce3fe234bd3912c2580820\",\"name\":\"Yuan Ji\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/75e5ae238a8868d317d02621afc36017d01bfd867c5704dc7a64dcce40a240b6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/75e5ae238a8868d317d02621afc36017d01bfd867c5704dc7a64dcce40a240b6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/75e5ae238a8868d317d02621afc36017d01bfd867c5704dc7a64dcce40a240b6?s=96&d=mm&r=g\",\"caption\":\"Yuan Ji\"},\"description\":\"Yuan is a passionate Java programmer and open source evangelist. He is eager to learn new technologies and loves clean and beautiful application design. He lives in Edmonton, Canada as an independent consultant and contractor.\",\"sameAs\":[\"http:\\\/\\\/www.jiwhiz.com\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/jiwhiz\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/jiwhiz\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yuan-ji\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add RememberMe Authentication With Spring Security","description":"I mentioned in my post Add Social Login to Jiwhiz Blog that the RememberMe function was not working with Spring Social Security. Well, it is because the","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\/03\/add-rememberme-authentication-with-spring-security.html","og_locale":"en_US","og_type":"article","og_title":"Add RememberMe Authentication With Spring Security","og_description":"I mentioned in my post Add Social Login to Jiwhiz Blog that the RememberMe function was not working with Spring Social Security. Well, it is because the","og_url":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-03-08T17:00:26+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Yuan Ji","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/jiwhiz","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yuan Ji","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html"},"author":{"name":"Yuan Ji","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ab7cf96563ce3fe234bd3912c2580820"},"headline":"Add RememberMe Authentication With Spring Security","datePublished":"2013-03-08T17:00:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html"},"wordCount":510,"commentCount":3,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Security","Spring","Spring Security"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html","url":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html","name":"Add RememberMe Authentication With Spring Security","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2013-03-08T17:00:26+00:00","description":"I mentioned in my post Add Social Login to Jiwhiz Blog that the RememberMe function was not working with Spring Social Security. Well, it is because the","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/add-rememberme-authentication-with-spring-security.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":"Add RememberMe Authentication With Spring Security"}]},{"@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\/ab7cf96563ce3fe234bd3912c2580820","name":"Yuan Ji","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/75e5ae238a8868d317d02621afc36017d01bfd867c5704dc7a64dcce40a240b6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/75e5ae238a8868d317d02621afc36017d01bfd867c5704dc7a64dcce40a240b6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/75e5ae238a8868d317d02621afc36017d01bfd867c5704dc7a64dcce40a240b6?s=96&d=mm&r=g","caption":"Yuan Ji"},"description":"Yuan is a passionate Java programmer and open source evangelist. He is eager to learn new technologies and loves clean and beautiful application design. He lives in Edmonton, Canada as an independent consultant and contractor.","sameAs":["http:\/\/www.jiwhiz.com\/","http:\/\/www.linkedin.com\/in\/jiwhiz","https:\/\/x.com\/https:\/\/twitter.com\/jiwhiz"],"url":"https:\/\/www.javacodegeeks.com\/author\/yuan-ji"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/9554","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\/364"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=9554"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/9554\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=9554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=9554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=9554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}