Note that there are some explanatory texts on larger screens.

plurals
  1. POspring security 3.1 allow user to sign and proceed to restricted pages
    primarykey
    data
    text
    <p>I'm using Spring Security 3.1 for authentication and the login works fine. When a user signs up, I would like the user to proceed to the restricted pages without having to login.</p> <p>There are several similar questions on stackoverflow with slightly different answers and I've tried these, but nothing seems to work for me. Here's my security configuration:</p> <pre><code>&lt;http pattern="/resources/**" security="none" /&gt; &lt;http pattern="/login" security="none" /&gt; &lt;http pattern="/user/forgotPassword" security="none" /&gt; &lt;http pattern="/user/createAccount" security="none" /&gt; &lt;http&gt; &lt;intercept-url pattern="/**" access="ROLE_USER" /&gt; &lt;form-login login-page="/login" default-target-url="/defaultUrl" always-use-default-target="true" authentication-failure-url="/loginfailed" /&gt; &lt;/http&gt; </code></pre> <p>And here's my code (after user has been created and added to the database):</p> <pre><code>UsernamePasswordAuthenticationToken upaToken = new UsernamePasswordAuthenticationToken(user.getName(), user.getPassword()); request.getSession(); upaToken.setDetails(new WebAuthenticationDetails(request)); Authentication auth = authenticationManager.authenticate(upaToken); SecurityContextHolder.getContext().setAuthentication(upaToken); return "redirect:&lt;restricted-page&gt;"; </code></pre> <p>Instead of being redirected to the restricted page, the login page is displayed. What am I missing?</p> <p>I would also like to avoid the call to authenticate the user. It seems unnecessary because the user has just signed up. But deleting it doesn't seem to change anything.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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