Closed alexflav23 closed 9 years ago
any chance of trying shiro 1.2.0 so the lift verasion is the only diff?
@fmpwizard I've downgraded the dependencies to Shiro 1.2.0 and the problem persists.
thanks for trying, I'll try to make some time this week and see what I find (may be next week though), feel free to send a ping here if I don't post again.
@fmpwizard The error is the filter added to web.xml
, if I remove the Shiro specific environment listener and filter login works and there's no error anymore. Some of the redirects seem to fail because of that as well, but I guess those can be done manually.
@fmpwizard I've also tried Lift 2.6-M4 with Shiro 1.2.0 and unfortunately the issues persists. Is there a chance we can work to fix this asap? I'm very happy to help put in some hours so long as you have any ideas where to look for.
Having the simplest app that shows this issue would be great, something where we click one simple button and shows r problem
And I think I'll be able to look at it over the weekend
Diego Sent from my cell On Feb 20, 2015 9:32 PM, "Flavian Alexandru" notifications@github.com wrote:
@fmpwizard https://github.com/fmpwizard I've also tried Lift 2.6-M4 with Shiro 1.2.0 and unfortunately the issues persists. Is there a chance we can work to fix this asap? I'm very happy to help put in some hours so long as you have any ideas where to look for.
— Reply to this email directly or view it on GitHub https://github.com/timperrett/lift-shiro/issues/27#issuecomment-75351537 .
@alexflav23 while you are getting the sample project, I just noticed that we didn't have updated jars for the final 2.6 version of Lift, go ahead and use this version :
this is using lift 2.6 final, scala 2.10.4 and the lift-shiro version is 0.0.9-SNAPSHOT (not 0.0.8)
I'll be updating the readme now with the new version
@fmpwizard Many thanks for this, I've been using a custom spinoff. I will try this right now and hope it works.
@fmpwizard I've just tried using your version and the problem persists, specifically after login. The issue is I'm using a custom login mechanism, which will just call currentUser.login(token)
, but now that I think about it this doesn't do anything else to deal with the Lift pipeline which probably goes alongside Shiro.
I will try using the /login
POST url lift-shiro provides by default.
@alexflav23 If I'm following what you are saying, while you call currentUser.login(token)
, shiro still doesn't know you are logged in, so it tries to send you back to do the login, right?
along side publishing the updated version, I went ahead and fixed the example that comes with this project, so now you can
sbt project lift-shiro-example
>container:start
and go to http://127.0.0.1:8080 , enter admin / secret and you can see the plugin working
if you want, you can update that example with some code that does something similar to your currentuser.login(token)
and I can try to take a look
@fmpwizard Many many thanks for going through all the hassle. As far as I understood it, Shiro needs that method alone to know you are logged in. Please correct me if I am wrong.
My processing code looks like this. The lifty methods you don't recognise like applicative parsers are coming from https://github.com/websudos/util.
// the rest route
case ApiConfig.Prefix :: ApiConfig.Version :: "user" :: "login" :: Nil JsonPost data -> _ => {
AuthenticationController.login(data).async(401)
}
// This is the login method called above
def login(data: JValue): Future[LiftResponse] = {
json[LoginRequest](data).fold(
err => err.toJson(400).toFuture,
req => {
if (UserController.login(req))
OkResponse().toFuture
else
JsonUnauthorizedResponse().toFuture
}
}
)
}
// which then goes to
def login(req: LoginRequest): Boolean = {
val token = new UsernamePasswordToken(req.email, req.password, req.remember.getOrElse(false))
token.setRememberMe(remember)
val currentUser = SecurityUtils.getSubject
currentUser.login(token)
currentUser.isAuthenticated
}
So Shiro does think the authentication is complete, otherwise I wouldn't be getting HTTP 200 for those responses. Furthermore, the unit tests for the Database Realm and password matching extensively cover all the above methods + DB queries and so forth and they all consistently pass.
By looking at the stacktrace, it's Lift constantly calling:
at net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$96$$anonfun$apply$97.apply(LiftSession.scala:2050)
at net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$$anonfun$apply$96$$anonfun$apply$97.apply(LiftSession.scala:2050)
Somehow the cycle repeats itself until there's a StackOverflow Error.
@fmpwizard I've found the culprit, the after login redirect was surrounding a template called internal
, which instead of having HTML was trying to surround itself, hence the endless processing.
The error which was caused by the ShiroFilter itself appears to have vanished, so many thanks for everything. I think it's safe to close this, I will come back with more details if the problem re-emerges.
Awesome that it is working well now!
Hi Tim,
I will copy paste the stack trace I am currently dealing with. Tried several machines, all MacOSX, to see if it's not machine related. AWS Linux instances report the same problem.
This is particularly interesting as the entire set of tests for the Shiro framework work perfectly, everything from how users are created, authenticated, how passwords are encrypted etc. Bottom line, all test green, no errors.
This happens after a successful login done via
currentUser.login(new UsernamePasswordToken(..))
. But nothing is even hitting the application code, it's the ShiroFilter itself failing.I'm using a custom
lift-shiro
that runs on Lift 3.0-M1 and Shiro 1.2.3 with no other changes done.