Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Remember Me functionality in already configured spring OUTH and usernamepassword token authentication system
    text
    copied!<p>I have the following spring security configuration.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"&gt; &lt;!-- For S2OAuth endpoints --&gt; &lt;http pattern="/oauth/token" create-session="stateless" authentication-manager-ref="clientAuthenticationManager" entry-point-ref="oauthAuthenticationEntryPoint" xmlns="http://www.springframework.org/schema/security"&gt; &lt;intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" /&gt; &lt;anonymous enabled="false" /&gt; &lt;http-basic entry-point-ref="oauthAuthenticationEntryPoint" /&gt; &lt;!-- include this only if you need to authenticate clients via request parameters --&gt; &lt;custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER" /&gt; &lt;/http&gt; &lt;http use-expressions="true"&gt; &lt;!-- Authentication policy --&gt; &lt;form-login login-page="/signin" login-processing-url="/signin/authenticate" authentication-failure-url="/signin?error=1" /&gt; &lt;logout logout-url="/signout" delete-cookies="JSESSIONID" /&gt; &lt;!-- Remember Me --&gt; &lt;remember-me services-ref="rememberMeServices" key="myRememberMeKey" /&gt; &lt;!-- Authorization policy definition: TODO consider replacing with @Secured on @Controllers --&gt; &lt;intercept-url pattern="/" access="permitAll" /&gt; &lt;intercept-url pattern="/favicon.ico" access="permitAll" /&gt; &lt;intercept-url pattern="/members/**" access="permitAll" /&gt; &lt;intercept-url pattern="/groups/**" access="permitAll" /&gt; &lt;intercept-url pattern="/pubsub/**" access="permitAll" /&gt; &lt;intercept-url pattern="/resources/**" access="permitAll" /&gt; &lt;intercept-url pattern="/signup" access="permitAll" requires-channel="#{environment['application.secureChannel']}" /&gt; &lt;intercept-url pattern="/signin" access="permitAll" requires-channel="#{environment['application.secureChannel']}" /&gt; &lt;intercept-url pattern="/signin/*" access="permitAll" requires-channel="#{environment['application.secureChannel']}" /&gt; &lt;intercept-url pattern="/reset" access="permitAll" requires-channel="#{environment['application.secureChannel']}" /&gt; &lt;!-- TODO this would probably be better mapped to simply /invite?token={token} but not able to vary security policy here based on presence of a request parameter. Consider @Secured on @Controller. --&gt; &lt;intercept-url pattern="/invite/accept" access="permitAll" requires-channel="#{environment['application.secureChannel']}" /&gt; &lt;!-- TODO this should be restricted to admin users only --&gt; &lt;intercept-url pattern="/admin/**" access="permitAll" /&gt; &lt;intercept-url pattern="/**" access="isAuthenticated()" requires-channel="#{environment['application.secureChannel']}" /&gt; &lt;custom-filter ref="resourceServerFilter" before="EXCEPTION_TRANSLATION_FILTER" /&gt; &lt;/http&gt; &lt;authentication-manager alias="authenticationManager"&gt; &lt;authentication-provider ref="usernamePasswordAuthenticationProvider" /&gt; &lt;/authentication-manager&gt; &lt;bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased" xmlns="http://www.springframework.org/schema/beans"&gt; &lt;constructor-arg&gt; &lt;list&gt; &lt;bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter" /&gt; &lt;bean class="org.springframework.security.access.vote.RoleVoter" /&gt; &lt;bean class="org.springframework.security.access.vote.AuthenticatedVoter" /&gt; &lt;/list&gt; &lt;/constructor-arg&gt; &lt;/bean&gt; &lt;bean id="jdbcRememberMeRepository" class="com.springsource.greenhouse.rememberme.JdbcRememberMeRepository" xmlns="http://www.springframework.org/schema/beans"/&gt; &lt;bean id="coreUserDetailsService" class="com.springsource.greenhouse.rememberme.RememberMeUserDetailsService" xmlns="http://www.springframework.org/schema/beans"/&gt; &lt;bean id="rememberMeServices" class="org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices" xmlns="http://www.springframework.org/schema/beans"&gt; &lt;property name="tokenRepository" ref="jdbcRememberMeRepository" /&gt; &lt;property name="userDetailsService" ref="coreUserDetailsService" /&gt; &lt;property name="key" value="myRememberMeKey" /&gt; &lt;property name="alwaysRemember" value="true" /&gt; &lt;/bean&gt; &lt;!-- For S2OAuth endpoints --&gt; &lt;authentication-manager id="clientAuthenticationManager" xmlns="http://www.springframework.org/schema/security"&gt; &lt;authentication-provider user-service-ref="clientDetailsUserService" /&gt; &lt;/authentication-manager&gt; &lt;beans:bean id="clientDetailsUserService" class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService"&gt; &lt;beans:constructor-arg ref="clientDetails" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="oauthAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"&gt; &lt;beans:property name="realmName" value="greenhouseApi" /&gt; &lt;/beans:bean&gt; &lt;beans:import resource="security-oauth-provider.xml" /&gt; &lt;/beans:beans&gt; </code></pre> <p>When I tick the remember-me checkbox , I see my remember-me database is populated as shown in the snapshot. Now I close the browser and try to access the url which needs sign-in. I am able to see the page. Now here I am confused about whether I am able to see the page because of login or because of remember-me. Secondly I see in the remember-me database table the last date is not updated. What can be the reasons for this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload