ComponentSpace SAML v2.0 for .NET 使用介绍
下载地址:http://samlsso.codeplex.com/
以下描叙参考版本为其官网最新版本2.5.0.6。相对2.4版本,2.5有了很大改进,很多接口方法都变了。使用起来更方便,易懂。
广告:
使用简便,文档实例丰富。
1,基础知识
SSO,SAML.自行google。
2,使用步骤:
a,安装,安装完毕后在安装目录 ComponentSpace SAML v2.0 for .NET下有各个版本的解决方案。你也可以移步到Examples\SSO\HighLevelAPI。在移步的过程中,你会发现其他文件夹,你可以先去看那些文件也可以后面再看。以下使用步骤参考了Documentation\SAML v2.0 Developer Guide.pdf
b,导入证书。我打开的是2012版本。展开ExampleIdentityProvider和ExampleServiceProvider工程。导入idp.pfx和sp.cer。其余证书忽略。
打开两个工程下的saml.config和web.config,浏览下,可能对一些疑问会有所帮助。关于本步骤的证书导入,你就会发现在saml.config中有一段如下配置
<IdentityProvider Name="urn:componentspace:ExampleIdentityProvider"
CertificateFile="idp.pfx"
CertificatePassword="password"/>
c,发布站点
编译这两个工程,可以通过发布程序直接建立应用;也可以选择发布到一个目录,然后也在iis新建两个应用程序,应用程序路径指向发布的目录。注意的是应用程序名称同工程名称。应用程序先放在默认站点下,一半是default下。到了实际应用的时候,这些名称,站点都是可以改的,默认配置在saml.config下:
<PartnerServiceProvider Name="urn:componentspace:ExampleServiceProvider"
WantAuthnRequestSigned="false"
SignSAMLResponse="true"
SignAssertion="false"
EncryptAssertion="false"
AssertionConsumerServiceUrl="http://localhost/ExampleServiceProvider/SAML/AssertionConsumerService.aspx"
SingleLogoutServiceUrl="http://localhost/ExampleServiceProvider/SAML/SLOService.aspx"
CertificateFile="sp.cer"/>
<PartnerIdentityProvider Name="urn:componentspace:ExampleIdentityProvider"
SignAuthnRequest="false"
WantSAMLResponseSigned="true"
WantAssertionSigned="false"
WantAssertionEncrypted="false"
SingleSignOnServiceUrl="http://localhost/ExampleIdentityProvider/SAML/SSOService.aspx"
SingleLogoutServiceUrl="http://localhost/ExampleIdentityProvider/SAML/SLOService.aspx"
CertificateFile="idp.cer"/>
d,运行。ExampleServiceProvider和ExampleIdentityProvider和两个的default.aspx顺便你先浏览那个,第一次都会先到ExampleIdentityProvider要求输入密码,密码为password,保存在ExampleIdentityProvider的web.config中:
<authentication mode="Forms">
<forms name="ExampleIdentityProvider" loginUrl="login.aspx">
<credentials passwordFormat="Clear">
<user name="idp-user" password="password"/>
</credentials>
</forms>
</authentication>
3,总结
是不是很简单,直接把demo拿到项目中用,只需要从安装证书开始,替换成自己的证书,自己的站点。把authentication换成自己的验证。authentication这一段在ExampleIdentityProvider下的login页面里:
if (FormsAuthentication.Authenticate(userNameTextBox.Text, passwordTextBox.Text)) {
FormsAuthentication.RedirectFromLoginPage(userNameTextBox.Text, false);
} else {
errorMessageLabel.Text = "Invalid credentials. The user name and password should be \"idp-user\" and \"password\".";
}
本文旨在做个推介,其余logout等等可以参看guid文档。还要啰嗦一句的是,当初我还关注怎么从认证中心传值到本地,看看ExampleIdentityProvider下的saml/SSOService.aspx.cs
IDictionary<string, string> attributes = new Dictionary<string, string>();
foreach (string key in WebConfigurationManager.AppSettings.Keys) {
if (key.StartsWith(AppSettings.Attribute)) {
attributes[key.Substring(AppSettings.Attribute.Length + 1)] = WebConfigurationManager.AppSettings[key];
}
}
SAMLIdentityProvider.SendSSO(Response, userName, attributes);
以及ExampleServiceProvider下的saml/AssertionConsumerService.aspx.cs:
SAMLServiceProvider.ReceiveSSO(Request, out isInResponseTo, out partnerIdP, out userName, out attributes, out targetUrl);
可以发现,容器就是attributes。
至于MVC在同个目录有example。大致结构原理一样。
搭建一个SSO就是这么简单。从此PM再也不担心你的学习了。
ComponentSpace SAML v2.0 for .NET 使用介绍的更多相关文章
- JuCheap V2.0响应式后台管理系统模板正式发布beta版本
JuCheap V1.* 查看地址: http://blog.csdn.net/allenwdj/article/details/49155339 经过半年的努力,JuCheap后台通用响应式管理后台 ...
- 【JS】heatmap.js v1.0 到 v2.0,详细总结一下:)
前段时间,项目要开发热力图插件,研究了heatmap.js,打算好好总结一下. 本文主要有以下几部分内容: 部分源码理解 如何迁移到v2.0 v2.0官方文档译文 关于heatmap.js介绍,请看这 ...
- 微信快速开发框架(六)-- 微信快速开发框架(WXPP QuickFramework)V2.0版本上线--源码已更新至github
4月28日,已增加多媒体上传及下载API,对应MediaUploadRequest和MediaGetRequest ------------------------------------------ ...
- Restful.Data v2.0发布,谢谢你们的支持和鼓励
v1.0发布后,承蒙各位博友们的热心关注,也给我不少意见和建议,在此我真诚的感谢 @冰麟轻武 等朋友,你们的支持和鼓励,是这个开源项目最大的推动力. v2.0在除了细枝末节外,在功能上主要做了一下更新 ...
- ArcGIS Runtime for Android开发教程V2.0(4)基础篇---MapView
原文地址: ArcGIS Runtime for Android开发教程V2.0(4)基础篇---MapView - ArcGIS_Mobile的专栏 - 博客频道 - CSDN.NET http:/ ...
- ArcGIS Runtime for Android开发教程V2.0(3)基础篇---Hello World Map
原文地址: ArcGIS Runtime for Android开发教程V2.0(3)基础篇---Hello World Map - ArcGIS_Mobile的专栏 - 博客频道 - CSDN.NE ...
- ArcGIS Runtime for Android开发教程V2.0(2)开发环境配置
原文地址: ArcGIS Runtime for Android开发教程V2.0(2)开发环境配置 - ArcGIS_Mobile的专栏 - 博客频道 - CSDN.NET http://blog.c ...
- ArcGIS Runtime for Android开发教程V2.0(1)基本概念
原文地址: ArcGIS Runtime for Android开发教程V2.0(1)基本概念 - ArcGIS_Mobile的专栏 - 博客频道 - CSDN.NET http://blog.csd ...
- Web电子商务网(三层)V2.0源码
Web电子商务网(三层)V2.0源码 源码描述: 一.源码特点 采用三层架构开发,购物车功能 二.功能介绍 前台集成了产品在线展示,用户注册.在线调查.在线投稿 后台有类别管理\图书管理\订单 ...
随机推荐
- OD 实验(十二) - 对一个 Delphi 程序的逆向
程序: 运行程序 界面显示的是未注册 点击 Help -> About 点击 Use Reg Key 这里输入注册码 用 PEiD 看一下 该程序是用 Delphi 6.0 - 7.0 写的 逆 ...
- 深入浅出 Java Concurrency (10): 锁机制 part 5 闭锁 (CountDownLatch)
此小节介绍几个与锁有关的有用工具. 闭锁(Latch) 闭锁(Latch):一种同步方法,可以延迟线程的进度直到线程到达某个终点状态.通俗的讲就是,一个闭锁相当于一扇大门,在大门打开之前所有线程都被阻 ...
- Centos7 / RHEL 7 双网卡绑定
http://www.cnblogs.com/hukey/p/6224969.html 1. 简要 双网卡绑定技术在centos7中使用了teaming技术,而在rhel6/centos7中使用 ...
- Spring Session 学习记录1
先写些废话 新公司项目是有用到redis,之前老公司使用的缓存框架是ehcache.我redis并不熟悉.看过介绍以后知道是个nosql..既然是个数据库,那我想操作方法和jdbc操作关系数据库应该差 ...
- ES6中新添加的Array.prototype.fill
用法 array.fill(start=0, end=this.length) 示例 [1, 2, 3].fill(4) // [4, 4, 4] [1, 2, 3].fill(4, 1) // [1 ...
- input子系统分析之三:驱动模块
内核版本:3.9.5 本节将以even handler来分析设备的注册和打开的过程,分析之前不妨回顾一下上节介绍的数据结构. 结合前两节分析可知,input子系统分为3层,最上一层是event han ...
- MYSQL的随机查询的实现方法
的确是那么回事. MYSQL的随机抽取实现方法.举个例子,要从tablename表中随机提取一条记录,大家一般的写法就是:SELECT * FROM tablename ORDER BY RAND() ...
- Camera & Render
1.void Render(); Description Render the camera manually. This will render the camera. It will use th ...
- java基础之HashSet如何保证对象的唯一性
首先Set集合是无序的 不可重复的 add的时候判断对象是否重复是用的equals HashSet<String> 存储String类型的数据时是可以保证数据的唯一性的 因为String类 ...
- Nginx源码完全注释(4)ngx_queue.h / ngx_queue.c
队列头文件ngx_queue.h #include <ngx_config.h> #include <ngx_core.h> #ifndef _NGX_QUEUE_H_INCL ...