【问题标题】:Sustainsys/Saml2 - Do not use SAML2 for some pagesSustainsys/Saml2 - 不要对某些页面使用 SAML2
【发布时间】:2022-07-18 23:25:42
【问题描述】:

之前我们的 Web 应用程序 (NET Framework 4.8) 使用 Windows 身份验证,然后我们切换到 Sustainsys/Saml2 与 Startup.cs 和 OWIN 登录。

事实证明,我们需要对某些页面禁用此身份验证:

  • 由任务计划程序运行的后台脚本(aspx 页面)
  • 2 个外部 API 控制器 (GET/POST),使用来自 3rd 方应用程序的登录/密码(不是基于 SAML2 的登录,只是 https + 基本身份验证)。

是否可以为这些页面/文件夹禁用 SAML2,以便我可以使用 Windows 身份验证或我们的自定义身份验证?

任务计划程序不支持 saml2 等和外部第三方应用程序,它们通过存储在其配置登录名/密码中进行连接。

据我所知,SAML2 需要通过网络弹出窗口进行人工交互(在我们的例子中是天蓝色),并且不能自动化。

web.config 中的设置不会进行任何更改

 <location path="pages/scripts">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>

【问题讨论】:

  • 事实证明,SAML2 本身并不是为非人机交互而设计的,因此(据我所知)不可能使用来自 3rd 方应用程序(例如 exe 文件)的已知登录名和密码以编程方式登录.有人说使用 Web Control 并模拟输入登录名和密码
  • 也许可以配置 SAML 以覆盖部分站点
  • SAML2 使用 Azure 作为身份提供者

标签: saml-2.0 sustainsys-saml2


【解决方案1】:

问题已通过使用 OAuth(令牌)和 SAML 解决。如果在 OWIN Startup.cs 中将 OAuth 放在 SAML 之前,即使激活了 SAML,令牌 API 也将起作用(我认为 SAML 代码看到 Thread.CurrentPrincipal 有一些用户,因此跳过了 SAML 代码)

        using System;
        using System.Web.Http;
        
        using Microsoft.Extensions.DependencyInjection;
        using Microsoft.Owin;
        using Owin;
        
        using BundleTable = System.Web.Optimization.BundleTable;
        ////
        
        [assembly: OwinStartup(typeof(MyApplication.App_Start.Startup))]
        
        namespace MyApplication.App_Start
        {
            public class Startup
            {
                // Configure the HTTP request pipeline.
                public void Configuration(IAppBuilder app)
                {
                    ServiceCollection services = new ServiceCollection();
                    ConfigureServices(services);
        
                    OAuthConfiguration oauthConfig =
                        MyConfigurationManager.ReadOAuth();
                    OAuthSetup oauth = new OAuthSetup(app, oauthConfig); 
    /* 
    IdentityServer 3
    app.UseJwtBearerAuthentication,  
    app.UseClaimsTransformation */
    
                    oauth.Use(); 
        


                    SamlConfiguration samlConfig =
                        MyConfigurationManager.ReadSaml();
                    SamlSetupSustainsys saml = new SamlSetupSustainsys(app, samlConfig);

/*
Sustainsys
app.UseSaml2Authentication(options);*
/
                    saml.Use(); 
        
                    WebApiConfig.Register(config);
                    app.RequireAspNetSession();
                    app.UseWebApi(config);
        
                    BundleTable.EnableOptimizations = false;
        
                    BundlingConfig.Register(BundleTable.Bundles);
                }
        
                // Add services to the container.
                public void ConfigureServices(IServiceCollection services)
                {
                    //services.AddMvcCore();
                }
            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-27
    • 1970-01-01
    • 1970-01-01
    • 2019-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多