Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:23:20+00:00 2026-06-05T03:23:20+00:00

In my application I have a top level entity called Organization. The relationship between

  • 0

In my application I have a top level entity called Organization. The relationship between User and Organization is many-to-many.

Because of this I could have the following scenario:

  • UserA has role ROLE_ADMIN for OrganizationA
  • UserA has role ROLE_USER for OrganizationB

I need to ensure that when UserA accesses resources for OrganizationB he is not doing it as an ADMIN. So I need an additional check that the user has the correct roles at the organization level. Is there anything built into Spring Security that allows for this? If not, does anyone know what the best way would be to about solving this?

UPDATE: A bit more information…

A User logs in and chooses which org they want to work with. That is stored in the session. Beyond that, URLs are locked down with the Secured annotation. What that means is that if UserA were to log in and select OrgA, they should be able to access /admin/user/create however, if they log in and choose OrgB they should not have access to that URL.

The long way is to add additional checks in every method where this matters. So call some service method that says “ok, you’re an admin for OrgA but not for OrgB and you’re logged in using OrgB, so deny this request”.

I’m hoping for a more grails / spring-security way of handling this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:23:22+00:00Added an answer on June 5, 2026 at 3:23 am

    You can probably do this by using a custom AccessDecisionVoter. The vote method will supply you with the “configuration attributes” for the resource (method or URL), which will typically be the required roles, and you can obtain the current user’s roles/authorities either directly from the Authentication object, or by reading the current org and selecting the appropriate roles for the user.

    I’m assuming that you have some way of differentiating the user’s roles, based on the org they’ve selected.

    Essentially, you’d be writing an extended version of the standard RoleVoter, which takes the organization into account.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a top level application called SearchApp which has a sub-app called TeamApp
I have a silverlight class library (not a top-level application) with several user controls
I have an application with a UITabBarController at its top level. I track which
My application has several independent top-level windows, which all have completely different functions/workflows. I
I have an application that has a top level navigation menu which consists of
In my application I have a Form that for one of the top level
I have a Winforms application that uses show multiple top-level windows: Form1 form1 =
I created a top level directory called 'maintenance' in my Ruby on Rails application.
I'm referring to this article here http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/ In my current application I have two
I'm working on an image processing application where I have two threads on top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.