具有Angular Frontend和.NET后端的Azure SSO的SAML配置

发布于 2025-02-03 18:00:04 字数 736 浏览 2 评论 0原文

我正在尝试为Azure SSO配置SAML,并遵循此示例:

https://matthijs.hoekstraonline.net/2020/04/14/authenticate-an-authenticate-an-azure-azure-av-ad-user-user-user-with-saml-for -asp-net核/

但是,我会收到以下错误:

“访问xmlhttprequest,请访问“ https://login.microsoftonline.com/../ (从“ https:// localhost:44 ..”重定向 “ http:// localhost:4200'已被CORS策略阻止:否 请求的“访问控制”标头 资源。”

我被告知我不需要在Angular中做任何事情,并且在.NET中进行配置就足够了。我已经看到了其他人也在使用JWT身份验证的答案。我无法理解如果不使用JWT可以实现这一点?

PS我使用的是REST API,而不是MVC。

I am trying to configure SAML in .NET for Azure SSO and I followed this example:

https://matthijs.hoekstraonline.net/2020/04/14/authenticate-an-azure-ad-user-with-saml-for-asp-net-core/

However, I get the following error:

"Access to XMLHttpRequest at "https://login.microsoftonline.com/../
(redirected from "https://localhost:44.." from origin
"http://localhost:4200' has been blocked by CORS policy: No
'Access-Control-Allow-Origin' header is present on the requested
resource."

I have been told that I need not do anything in Angular and configuring in .NET will suffice. I have seen answers where others are using JWT authentication as well. I am unable to understand if this can be achieved without using JWT?

P.S. I am using REST API and not MVC.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜雨飘雪 2025-02-10 18:00:04

当我首次连接前端和后端时,我遇到了类似的错误(在请求的资源上没有“访问控制”标头。在我的情况下,解决方案是在< system.webserver>的后端web.config中添加CORS配置。允许从给定域中访问。这也允许从您的前端角传递到后端应用程序。

        <cors enabled="true">
            <add origin="<Front End Domain>" allowCredentials="true">
                <allowMethods>
                    <add method="GET" />
                    <add method="POST" />
                    <add method="PUT" />
                    <add method="OPTIONS" />
                </allowMethods>
                <allowHeaders>
                    <add header="content-type" />
                    <add header="accept" />
                </allowHeaders>
            </add>
        </cors>

I had experienced a similar error (No 'Access-Control-Allow-Origin' header is present on the requested resource.) when I was first connecting my front end and back end. The solution in my case was to add cors configurations to the ?Backend web.config under <system.webServer> to allow access from the given domain. This also allows for credentials to be passed to the backend application from your front end Angular.

        <cors enabled="true">
            <add origin="<Front End Domain>" allowCredentials="true">
                <allowMethods>
                    <add method="GET" />
                    <add method="POST" />
                    <add method="PUT" />
                    <add method="OPTIONS" />
                </allowMethods>
                <allowHeaders>
                    <add header="content-type" />
                    <add header="accept" />
                </allowHeaders>
            </add>
        </cors>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文