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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:13:00+00:00 2026-06-10T22:13:00+00:00

I am very new to Spring security and my problem is as follows: I

  • 0

I am very new to Spring security and my problem is as follows:

I have a member mysql table that contains information about the website’s members, including their usernames, passwords and roles. So far so good: I can use this table to configure a <jdbc-user-service.

However I also want to have a super user that is not going to be in the member table.

  1. Is it possible and recommended to have this super-user in an in-memory user repository and therefore mix jdbc user service with in-memory user service? If so how?
  2. If 1. is not possible perhaps I can have a second mysql table called for instance moderator. Then what sort of sql query would I need to authenticate against these two tables?
  • 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-10T22:13:02+00:00Added an answer on June 10, 2026 at 10:13 pm

    Collissions

    The problem with multiple repositories is that you need to ensure that you differentiate which user is which. For example assume your data looks like the following

    member table

    username
    ----------------------
    member
    

    moderator table

    username
    ----------------------
    moderator
    

    Then you have some data associated to your users

    data table

    username          value
    ----------------------------------------
    moderator         secret
    

    What now happens if you get a collision? For example, a user signs up and your member table now looks like this:

    member table

    username
    ----------------------
    member
    moderator
    

    Which moderator owns the data? There is no way to distinguish between the two users.

    Alternative Approach

    The alternative approach would be to use a mapping of users to roles. It would be to use something like this:

    member table

    username           is_moderator
    ----------------------
    member             false
    moderator          true
    

    Then when a user tries to sign up for with an existing username, there is a constraint violation so you do not need to differentiate between the two. Of course you could map the roles using another table. This is what Spring Security does normally using the authorities table.

    Using multiple UserDetailsService

    If you really want to use multiple user repositories anyways, you can simply declare multiple UserDetailsService entries in your configuration. An in memory configuration example is shown below:

    
      <authentication-manager>
        <authentication-provider>
          <jdbc-user-service .. />
        </authentication-provider>
        <authentication-provider>
          <user-service>
            <user username="moderator" 
                password="password"
                authorities="ROLE_MODERATOR"/>
          </user-service>
        </authentication-provider>
      </authentication-manager>
    

    If you want to do both in the database, you need to determine what your SQL queries for each table are and then add two elements. For example:

    
      <authentication-manager>
        <authentication-provider>
          <jdbc-user-service .. />
        </authentication-provider>
        <authentication-provider>
          <jdbc-user-service .. />
        </authentication-provider>
      </authentication-manager>
    

    Use the attributes to control your sql queries. You can refer to the Spring Security appendix for example queries.

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

Sidebar

Related Questions

I have a very specific problem. I have a user control (code below) That
I am very new to spring security . I picked up this book and
I have a very simple report in SSRS that is just a table with
Very new to python and can't understand why this isn't working. I have a
Very new to FluentNHibernate, but I'm also excited about the area. I've recently started
Very new to XSL (and XML for that matter), but I need to step
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
I have a very annoying problem with the unreliable encryption and decryption of string
I am very new to asp.net mvc. I also have no enough background in
Okay, i am very very very new to Hibernate/Spring. I had to upgrade existing

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.