【问题标题】:How to use Azure AD authentication with Redis Cache如何将 Azure AD 身份验证与 Redis 缓存结合使用
【发布时间】:2020-04-18 06:54:46
【问题描述】:

我创建了一个配置了 Azure AD 的 MVC 应用程序。所以所有的身份验证设置都是自动化的。

但我想将用户会话存储在 Azure Redis 缓存中。因为我将使用多个实例

我知道如何在 azure 中设置 redis 缓存。但是我可以从哪里在缓存中添加 Session 呢?

因为我只有这个代码

 public void ConfigureAuth(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        app.UseCookieAuthentication(new CookieAuthenticationOptions());

        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                ClientId = clientId,
                Authority = authority,
                PostLogoutRedirectUri = postLogoutRedirectUri
            });
    }

【问题讨论】:

    标签: c# azure azure-active-directory azure-redis-cache


    【解决方案1】:

    如果要将会话存储在redis中:

    ASP.NET Session State Provider for Azure Redis Cache

    执行完这些步骤后,您的应用程序就被配置为使用 Redis 缓存会话状态提供程序。在应用程序中使用会话状态时,它存储在 Azure Redis 缓存实例中。

    如果你想将 redis 用于会话缓存以外的东西:

    How to create a Web App with Redis Cache

    【讨论】:

    • 但是在这里我们如何检查会话中是否存在数据?或者它会通过配置文件中的配置发生?
    • 您可以像往常一样使用会话状态。请参阅答案中的引用。
    猜你喜欢
    • 1970-01-01
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多