gpt4 book ai didi

redis - Servicestack Authentication IsAuthenticated 始终为 false

转载 作者:IT王子 更新时间:2023-10-29 06:14:06 24 4
gpt4 key购买 nike

您好,我正在尝试使用 servicestack 提供的 OAuth 身份验证

plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[]     {
new BasicAuthProvider(), new LinkedInOAuth2Provider(new AppSettings()),
new GoogleOAuth2Provider(new AppSettings()) }));

//Use Redis Repo
var userRepository = new RedisAuthRepository(redisClientsManager);
container.Register<IUserAuthRepository>(userRepository);
//Register Users with redis
Plugins.Add(new RegistrationFeature());

通过 Google/Linked 成功验证后,在 redis AuthRepo 中包含此内容,我们可以看到即使在成功验证后 isAuthenticated 也是 False。

We can see that isAuthenticated is False

谁能告诉我更多关于 OAuth 的信息,因为它在移动方面有很多 secret 。

例如:我应该在 LinkedIn 控制台中提供什么重定向 URI ..!如果我为手机使用 OAuth ..?以及如何在每个 App StartUp 上刷新 session 。

最佳答案

您的屏幕截图未显示经过身份验证的用户 session ,该 session 具有 IsAuthenticated = true 并包含 ProviderOAuthAccess 集合中每个 OAuth 提供商返回的 OAuth 详细信息。

ServiceStack OAuth 现场演示

参见 httpbenchmarks.servicestack.net有关使用 Google 和 LinkedIn OAuth2 的工作现场演示的示例。 HttpBenchmarks Github Repo包括一个分步指南,解释如何在 ServiceStack 中配置 OAuth,包括应用程序设置配置示例以及如何配置 Glimpse 以检查 DotNetOpenAuth 错误。

mvc.servicestack.net Live Demo 是另一个示例,其中包含使用多个 Auth Provider 的工作配置。

使用 AppHost AppSettings

注册 OAuth Provider 时,您应该使用 AppHost 的 AppSettings 而不是注入(inject) new AppSettings() 这样所有 Auth Provider 都将使用相同的配置 AppSettings for your AppHost ,例如:

Plugins.Add(new AuthFeature(() => new AuthUserSession(), 
new IAuthProvider[] {
new BasicAuthProvider(),
new LinkedInOAuth2Provider(base.AppSettings),
new GoogleOAuth2Provider(base.AppSettings)
}));

关于redis - Servicestack Authentication IsAuthenticated 始终为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38807073/

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