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 8957339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:58:03+00:00 2026-06-15T14:58:03+00:00

We have an application where users can be created by an administrator and assigned

  • 0

We have an application where users can be created by an administrator and assigned roles to a particular type of entity.

For example, if the entity is called Student, the users of the application have different levels of privileges such as:

  • VIEWER – View Student details
  • EDITOR – Edit Student details
  • EXPORTER – Export Student details

The URIs for performing the above actions look like:

  • GET – /content/{classId}/{studentId}/view
  • PUT – /content/{classId}/{studentId}
  • GET – /content/{classId}/{studentId}/export
  • POST – /content/{classId}/{studentId}/export

Note that the URIs are of a dynamic nature. Also, a given user User A can be assigned VIEWER role for Class 1 and EXPORTER for Class 2.

In my spring-security configuration, I have only two authorities defined – ADMINISTRATOR and USER.

  • ADMINISTRATOR – can access everything
  • USER – can access everything except the /admin/* URI.

The roles VIEWER, EDITOR, EXPORTER are not spring-security roles. Now I have run into a problem while restricting users from accessing resources to which they don’t have the rights.

Also, if a user doesn’t have the EXPORTER right, he shouldn’t even see the Export button (placed somewhere on the application). Perhaps I can do this using the spring’s security taglib. But that’s another issue altogether.

I can make them spring-security aware but the question is where do I put my logic of reading {studentId} (@PathVariable) and match it against the current logged in user to check if he has the access to it.

I even thought of the idea of creating a filter / HandlerInterceptor that listens on /content/*. But I will have to do ugly things like parsing the URI, extracting the second path parameter myself and then checking against the database.

Is there a more elegant, spring-security way of doing this?

Any thoughts welcome.

  • 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-15T14:58:04+00:00Added an answer on June 15, 2026 at 2:58 pm

    you can provide spring security your own implementation of SecurityExpressionHandler. Just extend DefaultWebSecurityExpressionHandler and override the createSecurityExpressionRoot. By default this method returns a instance of WebSecurityExpressionRoot. Your implementation could just extend this class and add additional methods, which you would use in your spring security configuration.

    here is how you provide your own implementation of SecurityExpressionHandler. The code comes from the spring security documentation:

    <security:global-method-security pre-post-annotations="enabled">
        <security:expression-handler ref="expressionHandler"/>
    </security:global-method-security>
    
    <bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
        <property name="permissionEvaluator" ref="myPermissionEvaluator"/>
    </bean>
    

    Does the answer provide enough information or do you need further assistance?

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

Sidebar

Related Questions

I have an application where users can store items. Now each type of account
I have created a django application. Using this app users can be created or
I have a survey application, where users can create surveys and give choices for
I have an application where multiple users can login(not simultaneously though!only a single user
I want to build a web application where users can register and have a
I have an Android application, backed by an API. To this API users can
I have an interactive web application powered by jQuery where users can manipulate visual
Im creating forum like application and I have textbox where users can enter tags
I have a application whereby a user can destroy other users attached to the
I have written an application that uses the Tinymce editor. The administrator can create

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.