惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
I
InfoQ
The Register - Security
The Register - Security
L
LangChain Blog
H
Help Net Security
The GitHub Blog
The GitHub Blog
S
Schneier on Security
博客园 - 【当耐特】
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
The Cloudflare Blog
H
Heimdal Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
雷峰网
雷峰网
N
Netflix TechBlog - Medium
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Exploit Database - CXSecurity.com
P
Privacy & Cybersecurity Law Blog
G
GRAHAM CLULEY
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V
Visual Studio Blog
博客园 - 聂微东
PCI Perspectives
PCI Perspectives
Last Week in AI
Last Week in AI
A
Arctic Wolf
宝玉的分享
宝玉的分享
T
The Blog of Author Tim Ferriss
S
Secure Thoughts
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
SecWiki News
SecWiki News
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Schneier on Security
Schneier on Security
P
Proofpoint News Feed
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AI
AI
Engineering at Meta
Engineering at Meta

博客园 - 阿福

TypeScript forms authentication failed the ticket supplied was invalid错误 (Windows Server 2008 + IIS 7.5) jQuery Mobile 1.1.1 RC1发布 HashSet<T> vs List<T> 不要用把无序GUID既作为主键又作为聚集索引 WCF Data Services 5.0 RTM发布 EF Power Tools Beta 2发布 Entity Framework 5性能方面的注意事项 jQuery Mobile 1.1.0 RC2发布 源码+幻灯片:学习HTML5/jQuery/ASP.NET MVC/EF Code First的绝佳资源Account at a Glance项目 使用Autofac在ASP.NET Web API上实现依赖注入 在Windows Azure上开发ASP.NET程序与在Windows Sever上有何不同 充分利用缓存来提高网站性能 ASP.NET MVC 4, ASP.NET Web API, ASP.NET Web Pages v2 (Razor)全部开源,并接受来自社区的贡献(contributions) EF5 beta2通过NuGet发布 Getting Started with HTML5 开发HTML5应用你需要了解的 WCF入门资源 jquery history plugin, url hash Run Tasks in an ASP.NET Application Domain ASP.NET 2.0: 生成Excel报表 VS 2008 hot-fix终于出来了 Images; How to create an HTTP handler to dynamically resize images and change quality. ASP.NET 2.0: Add build-in paging feature to repeater/为repeater添加内置分页功能 Tip/Trick ASP.NET 2.0: DropDownList DataBind Ajax类库、框架、工具包完全列表 怀旧啊 Search Box ASP.NET 2.0: Site Maps Checking All CheckBoxes in a GridView Efficient Data Paging and Sorting with ASP.NET 2.0 and SQL 2005 JavaScript Calendar Cool MSDN ASP.NET 2.0 GridView Control Article Do I have to cry for you Google无法访问 扯淡 狗*! Atlas Control Toolkit and Source Code for the Build-in Asp.Net 2.0 Providers Great New Advanced Article on ASP.NET 2.0 Master Pages ASP.NET 2.0:通过SqlDataSource绑定数据到普通控件 通过客户端扩展实现固定GridView表头功能 不使用ISAPI或IIS wildcard实现不带扩展名URL的转向 VS 2005 Web Application Project & Atlas Control Toolkit & CSS Control Adapter ASP.NET 2.0 Language Swithcer and Theme Swicher 多语言转换和多样式主题转换 How to use virtual path providers to dynamically load and compile content from virtual paths in  CSS: color style solution with css contexual selectors
ASP.NET 2.0: Forms Authentication Across domains
阿福 · 2010-01-01 · via 博客园 - 阿福

Keywords: single sign-on, across applications, across domains.

目标:实现对www.domain.com, sub1.domain.com, sub2.domain.com......的统一权限认证,既single sign-on 单点登录。说明一点,这里的每个地址对应的是一个独立的应用,也就是说在IIS里它们都是一个实际的站点。这和运用URL Rewiting技术实现的二级域名访问是不同的。URL重写实现的二级域名访问,对应的服务器端其实只是一个应用。实际上,IIS在处理这种二级域名的请求时,首先会检查有没有实际的站点配置在IIS上,如果有就会转向这个这个站点(这里讨论的就是这种情况下的跨域认证问题),如果没有就会转向主机头为空的那个站点,例如访问sub1.domain.com,如果IIS上没有配置这个域名,则iis就会把它转向domain.com上,而URL Writing是在domain.com这个应用上进行的。扯远了,还是回到single sign-on上。

实现:跨域的身份认证换句话说就是实现对认证信息的共享,ASP.NET的Forms认证,认证信息默认是加密存储在cookie里的,所以只要对cookie的加密方式,密钥,存储位置进行统一,认证信息就可以共享了。ASP.NET 2.0中的实现其实非常简单,只要修改一些配置信息就可以了。以sub1.domain.com, sub2.domain.com两个应用为例,为了实现两者的统一认证,必须保证下列配置的一致(标注红色的部分):

     <authentication mode="Forms">
      <forms name=".ASPXAUTH" loginUrl="signin.aspx" defaultUrl="~/default.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" domain="domain.com" enableCrossAppRedirects="true"/>
    </authentication>
    <machineKey validationKey='64E5DACAC6FB2B3E34FE06887639909EF2A180D6CDCB2463EAF098BA3E24A4FAC6C2A6E48C2F80FEE32A751C4B33D3EC70D73C59D64340E4CF7D9E44B0BA0077'   decryptionKey='BCCC63AF8E95BEA7393377CF2CF0CA35F1B5C09343404F44'   validation='SHA1'/>

另外,如果打算对角色信息也可以共享,例如在sub1.domain.com里认证为具有administrators角色的用户在进入sub2.domain.com后仍然是administrators,则要保证以下配置信息的一致:

    <roleManager cacheRolesInCookie="true" cookieName=".ASPXROLES" cookiePath="/" cookieProtection="All" cookieRequireSSL="false" domain="domain.com" cookieSlidingExpiration="true" cookieTimeout="30" createPersistentCookie="false" defaultProvider="SQLRoleProvider" enabled="true">
      <providers>
        <add name="SQLRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyConnectionString" applicationName="MyApp"/>
      </providers>
    </roleManager>

进而,如果想对认证信息统一进行管理,(如membersihp,roles),则应该对membersihp, rolemanager配置节的物理存储配置进行统一,主要是数据库的链接配置到统一的位置,applicationName配置成相同的。这时我们就会感觉到,ASP.NET 2.0 build-in的membersip, rolemanagement service,为我们实现集中的权限认证提供了便利。由于物理存储的结构相同,整合就变得十分方便。

附:下面这个链接可以用来生成machine key配置:
http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx
References:

MSDN Configuring Forms Authentication Across Applications
Creating a Single Sign-on for ASP.NET Application and Legacy ASP Application (Part II)
Single sign-on across multiple applications in ASP.NET
Single Sign-On for everyone - ASP.NET Forums