title: How to use Grails Spring Security Plugin to require logging in before access an action?
body: <p>I know that I can use annotation or Request mapping to restrict access to an ACTION by some specific ROLES. But now I have a different circumstance.</p>
  
  <p>My scenario is: every user of my site can create posts, and they can make their own post <strong>public, private, or only share to some other users</strong>. I implement sharing post by a database table PERMISSION, which specify if a user have the right to view a post or not.</p>
  
  <p>The problem arises here is that when a customer access a post through a direct link, how can I determine he/she have the privilege to view it? There's 3 circumstances:</p>
  
  <blockquote>
    <ol>
    <li>The post is public, so it can be viewed by anyone (include not-login
    user)</li>
    <li>The post is private, so only the login-owner can view it</li>
    <li>The post is sharing, it means only the login-user that is shared and the
    owner can view it.</li>
    </ol>
  </blockquote>
  
  <p>I want to process like this:</p>
  
  <blockquote>
    <ol>
    <li>If the requested post is public: ok.</li>
    <li>If the requested post is private/sharing: I want to redirect
    the customer to the login page; after
    logging in, the user will be re-direct
    to the page he wants to see.</li>
    </ol>
  </blockquote>
  
  <p>The problem here is that I can redirect the user to login controller/ auth action, but after that I don't know how to redirect it back. The link to every post is different by post_id, so I can't use <code>SpringSecurityUtils.securityConfig.successHandler.defaultTargetUrl</code></p>
  
  <p>Could anyone know a way to do this?</p>