【问题标题】:OpenId Connect Authentication PropertiesOpenId Connect 身份验证属性
【发布时间】:2021-09-07 02:28:46
【问题描述】:

在我的应用程序中,我将用户重定向到 Azure B2C 屏幕,以便他们可以更改自己的帐户。

我使用以下代码将用户传递给 B2C,其中包括对 properties.Items 的引用,我正在填充一个值:

var scheme = OpenIdConnectDefaults.AuthenticationScheme;
var properties = new AuthenticationProperties { RedirectUri = redirectUrl };

properties.Items["data1"] = "[possiblySensitiveData]";

return Challenge(properties, scheme);

当用户从 Azure B2C 屏幕返回到我的应用程序时,我可以从 data1 检索值。

是否有可能有人监听也可以检索存储在 ``data1``` 中的值?或者以这种方式传递的任何值是否默认加密?

【问题讨论】:

    标签: azure-ad-b2c openid-connect


    【解决方案1】:

    OpenIdConnectHandler 加密数据:https://github.com/dotnet/aspnetcore/blob/78ab4bd673c1040cf59400be76daf395062bc6a7/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectHandler.cs#L450

    message.State = Options.StateDataFormat.Protect(properties);
    

    此数据保护程序在此处设置:https://github.com/dotnet/aspnetcore/blob/52eff90fbcfca39b7eb58baad597df6a99a542b0/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectPostConfigureOptions.cs#L46-L48

    var dataProtector = options.DataProtectionProvider.CreateProtector(
        typeof(OpenIdConnectHandler).FullName!, name, "v1");
    options.StateDataFormat = new PropertiesDataFormat(dataProtector);
    

    它使用 ASP.NET Core 中的标准数据保护系统。

    【讨论】:

    • 谢谢,这就是我想要的确认。我不想暴露任何不应该的东西。
    猜你喜欢
    • 2016-06-28
    • 2018-07-01
    • 2019-03-14
    • 1970-01-01
    • 2018-04-12
    • 1970-01-01
    • 2017-12-14
    • 2020-05-28
    • 2019-06-26
    相关资源
    最近更新 更多