• PII is hidden.


    使用 Microsoft.AspNetCore.Authentication.JwtBearer 做验证的时候报错如下:

    IDX10503: Signature validation failed. Keys tried: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
    Exceptions caught:
    '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
    token: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.

    访问链接后, 只看到下面这段话:

    By default, we do not include any potential PII (personally identifiable information) in our >exceptions in order to be in compliance with GDPR.

    If you need to see the full information present in exceptions, please set >IdentityModelEventSource.ShowPII to true.

    IdentityModelEventSource.ShowPII = true;

    意思是出于安全的原因, 不会直接显示用户个人信息, 也就是 PII, 但是可以通过启用 IdentityModelEventSource.ShowPII = true 来查看完整的异常信息.

    这里有个官网的属性说明 IdentityModelEventSource.ShowPII Property

    完了之后, 又是一个懵逼点, 这货在哪里设置? 代码应该写在哪里?

    在 ASP.NET Core 项目中, 我们可以在 Startup.csConfigure() 中来直接配置该属性.

    // ...
    using Microsoft.IdentityModel.Logging
    
    namespace AspNetCoreShowPII
    {
        public class Startup
        {
            public void ConfigureServices(IServiceCollection services)
            {
                // ...
            }
    
            public void Configure(IApplicationBuilder app, IHostingEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
                else
                {
                    app.UseExceptionHandler("/Home/Error");
                }
    
                IdentityModelEventSource.ShowPII = true; // here
    
                // ...
            }
        }
    }
    

    然后就可以在异常信息中看到更加完整的信息了, 方便开发调试...

  • 相关阅读:
    codeforces 368B
    codeforces 651A
    codeforces 651B
    codeforces 732B
    codeforces 313B
    codeforces 550A
    codeforces 498B
    Linux C/C++基础——内存分区
    Linux C/C++基础——变量作用域
    Linux C/C++基础——Windows远程登录Linux
  • 原文地址:https://www.cnblogs.com/taadis/p/12133841.html
Copyright © 2020-2023  润新知