Results 1 to 2 of 2

Thread: access for logged in users regardless the role they have

  1. #1
    Join Date
    Aug 2004
    Location
    Kielce/Poland
    Posts
    3

    Default access for logged in users regardless the role they have

    Hi,

    for my application I need the following feature: some pages may be accessed only by users who are logged in - they do not need to have any role. I've achieved this by writing my own Voter, which recognizes LOGIN_REQUIRED attribute.

    Now I can write:

    \A/for-logged-in/*\Z=LOGIN_REQUIRED

    and my Voter lets the logged-in user in. It this attribute is not present Voter returns ACCESS_ABSTAIN.

    I wonder if this it the only and the best way of implementing this feature? Is it possible to write it simpler without my own voter? I know that I could give every user a special role ROLE_VISITOR, or something like that, but I'd like to avoid giving the user a role only to recognize the situation she/he is logged in.

    The most transparent solution would be when RoleVoter would recognize some keywords like:
    - ROLE_ANY (user should have at least one role - does it make sens anyway?),
    - ROLE_NOT_REQUIRED (the user should be logged in, but there is no need of having any roles - that make sens).

    Just a thought.
    --
    ant

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    I think it best to use an additional voter and the appropriate AccessDecisionManager implementation. For example, if you have your new MustBeLoggedInVoter and RoleVoter both voting on the same access decision, you need to carefully decide the desired behaviour (refer to the JavaDocs for AffirmativeBased, ConsensusBased, UnanimousBased for the subtle differences).

Similar Threads

  1. LDAPPasswordAuthenticationDao problem
    By benoit_m35 in forum Security
    Replies: 15
    Last Post: Jan 11th, 2006, 07:04 AM
  2. ROLE Question
    By rfulcher in forum Security
    Replies: 6
    Last Post: Sep 10th, 2005, 12:47 AM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Replies: 3
    Last Post: Jan 30th, 2005, 03:43 PM
  5. Role based security and Spring
    By spring04 in forum Security
    Replies: 1
    Last Post: Jan 19th, 2005, 03:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •