gpt4 book ai didi

playframework - 如何在 SecureSocial 中禁用提供程序?

转载 作者:行者123 更新时间:2023-12-04 03:43:31 25 4
gpt4 key购买 nike

我正在使用 Play Framework 2.3.2 与 Activator 1.2.3 并且正在试验 SecureSocial插件大师-SNAPSHOT。
Documentation说:

SecureSocial is designed in a modular architecture using plugins. Thismeans you can easily enable/disable them to include only what you needand also that you can change the built-in plugins for your ownimplementation if there is a need to customize how things work.

Plugins are defined in the play.plugins file under the conf directory.If you don't have that file yet create one and add:

[example list of plugins]

Only the authentication providers you include in the play.plugins file will appear on the loginpage.


(强调补充。)
我现在正在试用 SecureSocial 存储库中包含的 Java Demo。 play.plugins文件仅包含一行:
1500:com.typesafe.plugin.CommonsMailerPlugin
但如果我运行演示,所有提供程序都可用:
Running demo screenshot
如何关闭某些提供程序?根据文档,我希望注释掉 play.plugins 中的一些行,但没有人可以评论。
这里发生了什么?

最佳答案

如果未在插件文件中配置提供程序,您必须使用 master-SNAPSHOT - 而不是 2.1.3 - 它不再使用 Play 插件。相反,现在有一个 RuntimeEnvironment,您可以在其中配置可用于模块的服务(包括您需要实现的 UserService)。

默认环境包括所有提供程序,并且是演示使用的环境:https://github.com/jaliss/securesocial/blob/master/samples/java/demo/app/service/MyEnvironment.scala

master 有很多变化,文档还没有更新。要自定义可用的提供程序,您需要创建自己的扩展 RuntimeEnvironment.Default 的环境类并覆盖提供程序字段。例如:

class MyEnvironment extends RuntimeEnvironment.Default[DemoUser] {
override val userService: UserService[DemoUser] = new MyUserService()
override lazy val providers = ListMap(
include(
new FacebookProvider(routes, cacheService,oauth2ClientFor(FacebookProvider.Facebook))
),
include(
new FoursquareProvider(routes,cacheService,oauth2ClientFor(FoursquareProvider.Foursquare))
),
include(
new UsernamePasswordProvider[DemoUser](userService, avatarService, viewTemplates, passwordHashers)
)
)
}

在哪里 MyUserService是你的 UserService实现和 DemoUser是您要用来在您的操作中代表用户的类。

关于playframework - 如何在 SecureSocial 中禁用提供程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25104653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com