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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:30:03+00:00 2026-05-27T19:30:03+00:00

I am using Grails multi-tenant plugin with single-tenant mode. I have used spring security

  • 0

I am using Grails multi-tenant plugin with single-tenant mode. I have used spring security core plugin for authentication. I have used domain name resolver. User table is not common in default database. Every tenant db has it’s own user tables. It works fine except with the following 2 issues.

  1. When the client(tenant) user tries to login, sometime it hits the default database and say ‘User Not found’. If I try after refreshing the page(entering the url and press CTRL+F5), it logins correctly.

  2. I have a common user across the tenants with different access permissions. First I open my application in a browser with one tenant URL, login with the credentials and logged successfully. Next I open another tab in the same browser, enter the second url and login credentials. Here I am able to login to the application but I get the permissions of the 1st tenant. If I logout and refresh the page as mentioned or if I refresh the page before login and try, it works fine.

When I debugged, I found that before resolving the tenant, spring security hits the database with the previous db session.

How can I resolve 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-05-27T19:30:04+00:00Added an answer on May 27, 2026 at 7:30 pm

    When the request hits my login page, I get the tenantId and keep it in the session

    Integer tenantId = tenantResolver?.getTenantFromRequest(request)
    if (session.tenantId == null) {
       session.tenantId = tenantId
    }
    

    To get the logged in user details, I override the ‘loadUserByUsername’ method by implementing GrailsUserDetailsService and called within the transaction.

    UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
      def requst = SecurityRequestHolder.request
      def httpSession = requst.getSession(false)
      Integer tenant = httpSession.tenantId
      TenantUtils.doWithTenant (tenant) {
     User.withTransaction { status ->
           User user = User.findByUsername(username)
         }
      }
    }
    

    Now my issue is solved.

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

Sidebar

Related Questions

We're developing an app (using Grails Spring Security (formerly Acegi)) in which we'll have
I'm using grails with spring security and the JA-SIG CAS spring security plugin. One
I have just started using grails and installed the spring-security and spring-security-ui plugins. I
I'm using grails 2.0.0.M1 with few plugins (spring-security-core-1.2.1, spring-cache-1.3.1). No problems cleaning and comipling
using Grails 1.1.1 I have domain in Grails Person. Person can be related to
I'm using Grails and I have a local-plugin (that I wrote) that I'm using
I'm writing a web app using grails and spring-security 3.0.3 which requires me to
I'm using Grails 1.3.7. Let's say I have the domain objects Foo and Bar
We are using Grails Acegi plugin 0.5.1 for authentication and also the Captcha functionality.
We are using Grails [Spring+Hibernate] and have one service method with @Transactional(readOnly=true). During development

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.