简体   繁体   English

使用通过 Blazor WASM 使用 Windows 身份验证的 WebAPI

[英]Consume WebAPI that uses Windows Authentication with Blazor WASM

I am searching for hours now.我现在正在寻找几个小时。 I have a C# Blazor WASM SPA which get its data from a C# WebAPI (netcore 3.1).我有一个 C# Blazor WASM SPA,它从 C# WebAPI(netcore 3.1)获取数据。 For authentication I use JWT at the moment.对于身份验证,我目前使用 JWT。

I want to switch to a SSO-Solution.我想切换到 SSO 解决方案。 Since everything is running in company network, I would like to use Windows Authentication.由于一切都在公司网络中运行,我想使用 Windows 身份验证。

I managed to set up the API on IIS for Windows Authentication.我设法在 IIS 上设置了用于 Windows 身份验证的 API。 But I am really stuck with the Blazor App...但我真的坚持使用 Blazor 应用程序......

I tried to set it up on IIS with WinAuth/Anonym and to use a simple GET-Request for Login, hoping that NTLM negotiation would pass the credentials from the browser to the API.我尝试使用 WinAuth/Anonym 在 IIS 上设置它并使用简单的 GET 请求登录,希望 NTLM 协商将凭据从浏览器传递到 API。 Would be fine for me, if all further requests would use JWT.如果所有进一步的请求都使用 JWT,那对我来说没问题。 Even better if everything would work with WinAuth.如果一切都适用于 WinAuth,那就更好了。

But whatever I try, I won't work.但无论我怎么努力,我都不会工作。 Does anybody has a tutorial or a least a concept I could use for the start?有没有人有教程或至少我可以使用的概念?

Take a look at https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory?view=aspnetcore-3.1 .看看https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory?view=aspnetcore-3.1

This article shows how to secure both a Blazor front-end and .NET Core back-end api.本文展示了如何保护 Blazor 前端和 .NET Core 后端 api。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM