使用Kentor以编程方式配置sso设置 [英] Programatically configure sso settings using kentor

查看:140
本文介绍了使用Kentor以编程方式配置sso设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an MVC application (.Net Framework 4.5) which is been there for the last three years and using Forms Authentication mechanism. Now we want to integrate SSO feature with the help of Okta. Using KentorIT Authentication services I was able to integrate Okta with my mvc application. In that, all the configurations are being set in the web.config file (eg: entityId, signOnUrl etc.). Is there a way to programmatically configure these sso settings? I found that KentorAuthServicesSection is the class that we have to instantiate to do the process. Currently its reading the settings from configuration file.

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

因此使用自定义实现修改此ConfigurationManager.GetSection("kentor.authServices")部分将完成这项工作吗?还是有其他好的方法?

So modifying this ConfigurationManager.GetSection("kentor.authServices") part with a custom implementation will do the job? or is there any other good approach ?

推荐答案

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

You can just use the options classes directly -- no need to customize the GetSection.

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

I'm assuming you are using the Mvc module. In which case you want to set the options on the AuthServicesController during application startup, e.g.

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

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

With your own construction of these same configuration classes. For example:

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

此构造函数中的false告诉它 not 从配置系统读取.

The false in this constructor tells it not to read from the configuration system.

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

There is a larger example in the OWIN sample project: https://github.com/KentorIT/authservices/blob/v0.21.1/SampleOwinApplication/App_Start/Startup.Auth.cs#L54-L82

这篇关于使用Kentor以编程方式配置sso设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆