mkurz / deadbolt-2

An authorization module for the Play framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failure with @SubjectPreset not with @Restrict

zalito12 opened this issue · comments

Hello! I'm getting Auth Failure when I use @SubjectPresent and not when I use @Restrict...
I think I have the problem located but I cannot find a good reason about why this is happening.

On my breforeAuthCheck() method I set some data on context session to access it directly on getSubject(). I tested it with some examples with different roles (I use session to propagate user info and don't have to decode a token twice) and it worked. But when I use @SubjectPresent the session values are null.

Is there a problem with context when there is not a role check.

Thanks!

Are you doing anything in DeadboltHandler#beforeAuthCheck?

Sorry I mistake method names, beforeCorrect() is a private method I created and executes on DeadboltHandler#beforeAuthCheck. In breforeAuthCheck() I look up for Authorization header, verify a JWT token and propagate the user info over the context sessions.
When I make use of @Restrict(SOME_GROUP) it works perfectly but when I use @SubjectPresent and search for context session info I saved before it is null. I thought could be a problem with context when @SubjectPresent is used or may be my code, I will check it again.
What surprised me was that it works with Restrict and don't with SubjectPresent.

PD. I will edit my initial post to change method names, sorry.

In the SubjectPresent annotation, you need to set the forceBeforeAuthCheck property to true. Does that fix it?

Check the comments for that property for more details.

My bad, sorry. I didn't notice that. It's working now. Thank you.