我有一个Lift web应用程序,我想在其中提供csv下载链接。csv由Lift rest服务提供。
设置这个没有问题。但是,为了安全和流畅地工作,我需要使用已经建立的经过身份验证的web会话。
这是我当前使用其他rest服务进行的rest身份验证。是否存在web用户的角色,我可以在下面的?中添加;或者我完全没有抓住要点?
LiftRules.authentication = HttpBasicAuthentication("lift") {
case (`webshopUser`, `webshopPwd`, _) =>
userRoles(webshopRole :: Nil)
true
case (`mailingListUser`, `mailingListPwd`, _) =>
userRoles(mailingListRole :: Nil)
true
}
LiftRules.httpAuthProtectedResource.append {
case Req("rest" :: "mailingLists" :: _, _, _) => Full(mailingListRole)
case Req("rest" :: "mamberships" :: "year" :: _, _, _) => ???
case Req("rest" :: "memberships" :: _, _, _) => Full(webshopRole)
}发布于 2013-02-06 03:23:31
角色只是一个任意的权限,允许您控制对资源的访问。在您的应用程序中,您已经将webshopRole和mailingListRole定义为实现net.liftweb.http.auth.Role的变量。为了保护第二个请求,您需要决定是否:
webshopUser定义的帐户。在这种情况下,您可以使用Full(webshopRole).webshopRole的新角色,对于本例,我们将其命名为csvRole。然后,将该角色添加到HttpBasicAuthentication规则中,如:userRoles(webshopRole :: csvRole :: Nil)。在映射中,您将使用:Full(csvRole)https://stackoverflow.com/questions/14714850
复制相似问题