Re: [Lift] Forcing Authentication not working

2010-02-07 Thread Timothy Perrett
How odd - why dont you just match on the req unapply rather that this awkward 
sub match? 

You need to do something like:

LiftRules.httpAuthProtectedResource.prepend {
  case Req("restricted" :: _,_,_) => Full(AuthRole("admin"))
}

LiftRules.authentication = HttpBasicAuthentication("myrealm"){
  case ("admin", "password", req) => {
userRoles(AuthRole("admin"))
true
  }
  case (user, pass,_) => Log.warn("Attempted report login with: " + user + 
":" + pass); false
}

Cheers, Tim

On 6 Feb 2010, at 20:19, aw wrote:

> LiftRules.httpAuthProtectedResource.append {
>  case req :  Req => req.path match {
>case ParsePath("restricted" :: _, _, _, _) => restrictedRole
>case _ => Empty
>  }
> }

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.



[Lift] Forcing Authentication not working

2010-02-06 Thread aw
According to:

http://scala-tools.org/mvnsites-snapshots/liftweb/lift-base/lift-webkit/scaladocs/net/liftweb/http/LiftRules$object.html#httpAuthProtectedResource

It says that if I have a rule that responds with Empty, it means that
authentications is performed, but not an authorization check.  This is
what I need.  So, I have a rule something like:

LiftRules.httpAuthProtectedResource.append {
  case req :  Req => req.path match {
case ParsePath("restricted" :: _, _, _, _) => restrictedRole
case _ => Empty
  }
}

Alas, I can clearly see that my authentication is NOT being performed
for just any page.

Am I missing something, or is the documentation incorrect, or is this
a bug?  Note that I am using 2.0-M1.

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.