问题标签 [silhouette]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
281 浏览

scala - Scala未来链接和左/右

我在 PLAY 框架中有这段代码

我是 scala 的初学者,基本上我想要做的是验证对ws端点的请求。如果它通过了身份验证,那么我给它一个Flow[JsValue, JsValue, None]充当 WebSocket 连接,否则我需要返回一个Result. 我遇到的问题是我不太清楚如何正确设计期货。对于上下文,这是文档https://www.silhouette.rocks/docs/endpoints中经过身份验证的端点示例。

未编译的行如下:

我传递给的函数WebSocket.acceptOrResult[JsValue, JsValue]需要返回一个Future[Either[Result, Flow[In, Out, _]]]. 正如您在未编译的行中看到的那样,我正在尝试Right()使用Flow,但这并不完全正确。注释部分确实可以编译。这是编译错误

谢谢

0 投票
1 回答
144 浏览

silhouette - 无法在“剪影”中创建“环境”

我正在尝试创建EnvironmentinSilhouette但无法创建。我已经定义了IdentityandAuthenticator如下

接下来,我想我必须创建Environment. 为此,我编写了以下代码,但我坚持,因为我不明白如何传递Environment'sapply方法预期的不同参数

环境伴生对象的应用方法有签名

我知道我必须提供IdentityService. 我已经这样做了

用户定义如下

但是对于应用所需的其他值,我应该传递什么-authenticatorServiceImpl:AuthenticatorService[E#A],requestProvidersImpl:Seq[RequestProvider],eventBusImpl:EventBus

另外,我想我不必使用Guice,因为我正在使用编译时注入。那是对的吗?

更新我从更改SessionAuthenticatorServiceCookieAuthenticatorService尝试一些在线可用的代码。

似乎我对Silhouette提供一些默认实现的理解并不完全正确。我以为我可以简单地使用中SessionAuthenticatorService定义的伴随对象,https://github.com/mohiva/play-silhouette/blob/master/silhouette/app/com/mohiva/play/silhouette/impl/authenticators/SessionAuthenticator.scala但事实并非如此。查看在 中创建的一些代码ScalaModule,似乎我必须自己创建所需的对象,但我需要在我的 AppLoader 类(用于编译时 DI)而不是 ScalaModule(用于运行时 DI)中创建。但是,我仍然没有解决问题。我不知道如何创建signer所需的CookieAuthenticatorService

0 投票
1 回答
479 浏览

scala - 为什么我不能将伴随对象传递给函数

我正在研究剪影框架,并正在创建一个类型的变量Environment。它的伴生对象有签名

对于authenticatorServiceImpl参数,我认为我可以传递伴随对象SessionAuthenticatorService(定义在 中https://github.com/mohiva/play-silhouette/blob/master/silhouette/app/com/mohiva/play/silhouette/impl/authenticators/SessionAuthenticator.scala)但是当我尝试时:

我得到错误

com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticatorService.typ 不带参数。

我删除了()但又出现了另一个错误:

发现:SessionAuthenticatorService.type [错误] 必需:AuthenticatorService[components.SessionEnv#A]

看来我的概念是不健全的。为什么我不能通过SessionAuthenticatorService

0 投票
0 回答
24 浏览

playframework-2.6 - 是否可以看到 Macwire 生成的代码

是否可以看到wire宏生成的代码是什么

在上面的示例中,我想知道DefaultSecuredRequestHandler创建时传递了哪些参数。DefaultSecuredRequestHandler不是我的课。它是Silhouette图书馆的一部分。

我正在尝试创建一个实例,DefaultSecuredRequestHandler我需要传递BodyParser.Default给它,但我不知道从哪里得到它。但是,我在网上找到了一些代码,我们使用 Macwire 创建DefaultSecuredRequestHandler. 因此,我想知道是如何DefaultSecuredRequestHandler创建的。

0 投票
0 回答
126 浏览

playframework-2.6 - 什么是 BodyParsers.Default 以及如何将其传递给函数

我想创建在http://api.play.silhouette.rocks/5.0.0/com/mohiva/play/silhouette/api/actions/DefaultSecuredAction.html定义的以下类的实例

我不知道如何通过bodyParsertype Default。我正在使用编译时注入,因此我不能使用@Inject().

bodyParser类型play.api.mvc.BodyParsers.Default

到目前为止,我已经编写了以下代码

Default似乎在这里定义- https://www.playframework.com/documentation/2.6.0/api/scala/index.html#play.api.mvc.BodyParsers $

但是当我尝试使用它时,出现以下错误

0 投票
0 回答
227 浏览

silhouette - Silhouette 中的 CookieAuthenticator 和 SessionAuthenticator 有什么区别

我想基于 Cookie 的身份验证是 - 服务器创建一个难以猜测的 id 并将其发送到 cookie 中的客户端。然后,客户端将在 cookie 中的每个请求中将 id 发送到服务器。我想这也创建了一个会话。

问题 1 - CookieAuthenticatorinSilhouette像这样工作吗?case 类还允许定义此类 cookie的CookieAuthenticatorSettings不同属性。

问题 2 - 如果 Cookie 身份验证创建会话,它是什么SessionAuthenticator以及如何工作?它与 有何不同CookieAuthenticator

0 投票
1 回答
167 浏览

playframework-2.6 - 将剪影 v5.0 与 Play 2.6 集成

我正在尝试将剪影 v5.0 与 play 2.6 集成,但在运行应用程序时出现错误,这是我的 build.sbt 文件和错误。谢谢任何帮助。

这是错误:

0 投票
2 回答
436 浏览

scala - 如何映射未来的失败投影

在以下代码中,该函数应返回实例,Future[Result]但我无法这样做。代码查询数据库,数据库返回Future[User]。我认为我能够正确映射未来的成功部分,但不能正确映射失败部分。请参阅函数末尾的注释。

0 投票
0 回答
66 浏览

scala - Playframework [Scala]:使用 JWTAuthenticator 时使用公钥/私钥对

我正在考虑将带有 JWT 身份验证的 OAuth2 添加到使用 Scala 用 Playframework 编写的一堆微服务中。我想将 JWT 与 RS256 一起使用。我一直在看剪影的JWTAuthenticator,但它似乎不支持RS256开箱即用。

有没有人在 Silhouette 上使用 JWTRS256而无需编写自己的身份验证器?我只需要内部微服务通信的认证和授权。

0 投票
1 回答
189 浏览

scala - 即使我已经实现了它们,也会出现未实现的方法错误

我的Play, Silhouette,Cassandra应用程序中出现以下错误

class UsersRepository needs to be abstract, since: it has 6 unimplemented members. /** As seen from class UsersRepository, the missing signatures are as follows. * For convenience, these are usable as stub implementations. */ // Members declared in com.mohiva.play.silhouette.api.repositories.AuthInfoRepository def add[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo,authInfo: T): scala.concurrent.Future[T] = ???

def find[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo)(implicit tag: scala.reflect.ClassTag[T]): scala.concurrent.Future[Option[T]] = ???

def remove[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo)(implicit tag: scala.reflect.ClassTag[T]): scala.concurrent.Future[Unit] = ???

def save[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo,authInfo: T): scala.concurrent.Future[T] = ???

def update[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo,authInfo: T): scala.concurrent.Future[T] = ???

但是,在同一个文件中,我已经实现了它们

我究竟做错了什么?