【问题标题】:Configure Blazor WebAssembly with active directory federation services (AD FS)使用 Active Directory 联合服务 (AD FS) 配置 Blazor WebAssembly
【发布时间】:2022-10-13 17:52:29
【问题描述】:

我正在尝试通过本地公司 ADFS 对我的前端 Blazor WASM SPA 进行身份验证。但我很迷茫,有谁知道如何设置或指向一些资源?

我只能找到使用 Azure Active Directory 的解决方案,因为我们已经有一个本地 AD,所以我试图避免这种情况。

我的技术栈是:

  • Blazor WebAssembly
  • ASP.NET Core 6 Web API

【问题讨论】:

    标签: active-directory blazor openid-connect blazor-webassembly adfs


    【解决方案1】:

    好吧,我用Blazor WebAssembly with the Authentication library 弄明白了。

    // Program.cs
    builder.Services.AddOidcAuthentication(options =>
    {
        options.ProviderOptions.ClientId = "client-id-from-adfs";
        options.ProviderOptions.Authority = "https://<adfs-server>/adfs/";
        options.ProviderOptions.RedirectUri = "https://localhost:xxxx/login-callback";
    });
    

    我还使用chrome --incognito --ignore-certificate-errors 启动了 Chrome,以避免(开发)SSL 证书出现问题。

    编辑:

    之前的解决方案仍然存在一些问题,例如我无法通过IAccessTokenProvider 检索我的令牌,因为它没有正确设置。

    所以我使用了 MSAL 库 (Microsoft.Authentication.WebAssembly.Msal),它也可以通过 OAuth2/OpenID Connect 工作,同时仍然遵循 Blazor WebAssembly with the Authentication library 的说明。

    例子:

    // Program.cs
    
    // Instead of .AddOidcAuthentication()
    builder.Services.AddMsalAuthentication(options =>
    {
        options.ProviderOptions.Authentication.Authority = "https://<adfs-server>/adfs/";
        options.ProviderOptions.Authentication.ClientId = "client-id-from-adfs";
        options.ProviderOptions.Authentication.ValidateAuthority = true;
    });
    

    【讨论】:

      【解决方案2】:

      问题解决了吗?我有这个

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-22
        • 2023-04-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多