【问题标题】:Programatically configure sso settings using kentor使用 kentor 以编程方式配置 sso 设置
【发布时间】:2017-05-15 13:02:40
【问题描述】:

我有一个 MVC 应用程序 (.Net Framework 4.5),它在过去三年中一直存在并使用表单身份验证机制。现在我们想在 Okta 的帮助下集成 SSO 功能。使用 KentorIT 身份验证服务,我能够将 Okta 与我的 mvc 应用程序集成。其中,所有配置都在 web.config 文件中设置(例如:entityId、signOnUrl 等)。有没有办法以编程方式配置这些 sso 设置?我发现 KentorAuthServicesSection 是我们必须实例化以执行该过程的类。目前它从配置文件中读取设置。

 public class KentorAuthServicesSection : ConfigurationSection
 {
        private static readonly KentorAuthServicesSection current =
            (KentorAuthServicesSection)ConfigurationManager.GetSection("kentor.authServices");
 }

那么用自定义实现修改这个 ConfigurationManager.GetSection("kentor.authServices") 部分就可以了?还是有其他好的方法?

【问题讨论】:

    标签: okta kentor-authservices


    【解决方案1】:

    您可以直接使用选项类——无需自定义GetSection

    我假设您正在使用 Mvc 模块。在这种情况下,您希望在应用程序启动期间设置 AuthServicesController 上的选项,例如

    Kentor.AuthServices.Mvc.AuthServicesController.Options = myOptions;

    使用您自己构建的这些相同的配置类。例如:

    var spOptions = new SPOptions
    {
        EntityId = new EntityId("http://localhost:57294/AuthServices"),
        ReturnUrl = new Uri("http://localhost..."),
        //...
    };
    options = new KentorAuthServicesAuthenticationOptions(false)
    {
       SPOptions = spOptions
    };
    

    此构造函数中的false 告诉它不要从配置系统中读取。

    OWIN 示例项目中有一个更大的示例: https://github.com/KentorIT/authservices/blob/v0.21.1/SampleOwinApplication/App_Start/Startup.Auth.cs#L54-L82

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-24
    相关资源
    最近更新 更多