On 7/7/11 6:11 PM, dreamage wrote: > Thanks for the quick response. I understand you solutions, but I think that > my problem is a little bit more complex that I thought. > > My application serve multiple sites, and the main problem is that I have > only one "users" table in my database, with 3 columns, companyId, username > and password_hash. The username is unique per company but the same username > can exist in more than one company (so the primary key is companyId + > username).
This creates a problem for login. Maybe someone else has a better idea, but one way around this might be to extend UsernamePasswordToken to add the companyId and have your Realm's doGetAuthenticationInfo add the companyId (pulled from the extended AuthenticationToken) to the Principals collection (per Jared's suggestion above) and also use it in the query that gets the password for the user. Phil > > > Depending on the subdomain name (companyname.mysite.com), I select a > company, and then I would like all my calls to Shiro (login, permissions > check, ...) to take that into account so that my realm can use the companyId > in the queries. > > My first thought was to create one realm per company (using one spring > application context per company, or something like that), but I don't see > how the threadlocal model of Shiro would be able to handle that. > > Any thoughts on that ? > > Thanks > > Mathieu > > -- > View this message in context: > http://shiro-user.582556.n2.nabble.com/Subject-custom-data-from-database-tp6559272p6560652.html > Sent from the Shiro User mailing list archive at Nabble.com. >
