因项目需要,使用了耶鲁大学的Cas单点登录方案,在java中使用一直正常,但是在.Net中碰到了循环重定向的问题,反复测试后,总算解决了,最终的配置如下:

<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="casClientConfig" type="DotNetCasClient.Configuration.CasClientConfiguration, DotNetCasClient" />
</configSections>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings> <casClientConfig
casServerLoginUrl="http://192.168.101.100:8082/cas/login"
casServerUrlPrefix="http://192.168.101.100:8082/cas/"
serverName="http://192.168.101.109/SSOMvc"
redirectAfterValidation="true"
gateway="false"
renew="false"
singleSignOut="true"
ticketTimeTolerance="5000"
ticketValidatorName="Cas20"
serviceTicketManager="CacheServiceTicketManager"
gatewayStatusCookieName="CasGatewayStatus" /> <system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms
loginUrl="http://192.168.101.100:8082/cas/login"
timeout="30"
defaultUrl="~/Home/Index"
cookieless="UseCookies"
slidingExpiration="true"
path="/SSOMvc/" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<httpModules>
<add name="DotNetCasClient" type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient" />
</httpModules>
<sessionState mode="StateServer" cookieless="UseCookies" timeout="3600"></sessionState>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="DotNetCasClient" />
<add name="DotNetCasClient" type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime> <system.diagnostics>
<trace autoflush="true" useGlobalLock="false" />
<sharedListeners>
<!--
Writing trace output to a log file is recommended.
IMPORTANT:
The user account under which the containing application pool runs
must have privileges to create and modify the trace log file.
-->
<add name="TraceFile"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="F:\RunLog\DotNetCasClient.Log"
traceOutputOptions="DateTime" />
</sharedListeners>
<sources>
<!-- Provides diagnostic information on module configuration parameters. -->
<source name="DotNetCasClient.Config" switchName="Config" switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="TraceFile" />
</listeners>
</source> <!-- Traces IHttpModule lifecycle events and meaningful operations performed therein. -->
<source name="DotNetCasClient.HttpModule" switchName="HttpModule" switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="TraceFile" />
</listeners>
</source> <!-- Provides protocol message and routing information. -->
<source name="DotNetCasClient.Protocol" switchName="Protocol" switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="TraceFile" />
</listeners>
</source> <!-- Provides details on security operations and notable security conditions. -->
<source name="DotNetCasClient.Security" switchName="Security" switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="TraceFile" />
</listeners>
</source>
</sources>
<switches>
<!--
Set trace switches to appropriate logging level. Recommended values in order of increasing verbosity:
- Off
- Error
- Warning
- Information
- Verbose
-->
<!--
Config category displays detailed information about CasAuthenticationModule configuration.
The output of this category is only displayed when the module is initialized, which happens
for the first request following application/server startup.
-->
<add name="Config" value="Verbose"/> <!--
Set this category to Verbose to trace HttpModule lifecycle events in CasAuthenticationModule.
This category produces voluminous output in Verbose mode and should be avoided except for
limited periods of time troubleshooting vexing integration problems.
-->
<add name="HttpModule" value="Verbose"/> <!--
Set to Verbose to display protocol messages between the client and server.
This category is very helpful for troubleshooting integration problems.
-->
<add name="Protocol" value="Verbose"/> <!--
Displays important security-related information.
-->
<add name="Security" value="Verbose"/>
</switches>
</system.diagnostics>
</configuration>

注意:我测试时直接访问域名,不加具体的路径会一直“循环重定向”,例如:http://192.168.101.109/SSOMvc,这样测试的地址默认的defaultUrl为Home/Index,如果直接访问就会出现“循环重定向”,但是直接访问http://192.168.101.109/SSOMvc/Home/Index在登录后,重定向回来是正常的。但是在asp.net 中测试没这个问题,只有mvc才会碰到。

2014-11-26更新:后续重定向的问题在一位同事那里得到了解决,在mvc中forms的属性配置path=“/SSOMvc/”改为“/SSOMvc”,据说跟casClientConfig的属性serverName相对应,如果这里的路径最后面包含了斜杠,path的值中也应该包含。

Asp.net Mvc4 使用Cas单点登录的更多相关文章

  1. 【CAS单点登录视频教程】 第06集【完】 -- Cas认证 学习 票据认证FormsAuthentication

    目录 ----------------------------------------- [CAS单点登录视频教程] 第06集[完] -- Cas认证 学习 票据认证FormsAuthenticati ...

  2. SSO之CAS单点登录实例演示

    本文目录: 一.概述 二.演示环境 三.JDK安装配置 四.安全证书配置 五.部署CAS-Server相关的Tomcat 六.部署CAS-Client相关的Tomcat 七. 测试验证SSO 一.概述 ...

  3. cas 单点登录出现org.jasig.cas.client.util.CommonUtils.getResponseFromServer - 拒绝连接 Connection refused

    cas 单点登录出现org.jasig.cas.client.util.CommonUtils.getResponseFromServer - 拒绝连接 Connection refused 环境: ...

  4. CAS单点登录中文用户名乱码问题

    CAS单点登录中文用户名乱码问题,有两种情况 1. CAS server乱码 即在向server端提交用户名和密码时,发生了乱码,解决方法是: 打开WEB-INF/web.xml,在其它的Filter ...

  5. CAS单点登录系统整合——注册的问题

    最近一段时间在搞CAS单点登录系统,涉及到几个子系统的整合问题.对于注册,这里遇到了一个选择: 在子系统内完成注册,然后把信息同步到CAS系统: 在CAS系统中完成基本信息的注册,比如:用户名.邮箱. ...

  6. CAS单点登录之mysql数据库用户验证及常见问题

    前面已经介绍了CAS服务器的搭建,详情见:搭建CAS单点登录服务器.然而前面只是简单地介绍了服务器的搭建,其验证方式是原始的配置文件的方式,这显然不能满足日常的需求.下面介绍下通过mysql数据库认证 ...

  7. SSO之CAS单点登录详细搭建教程

    本教程是我个人编写,花费几个小时的时间,给需要学习的人员学习使用,希望能帮助到你们. [环境说明]:本文演示过程在同一个机器上的(也可以在三台实体机器或者三个的虚拟机上),环境如下: windows7 ...

  8. CAS单点登录配置[1]:准备工作

    关于CAS是什么这里就不在赘述,网友将它比喻成旅游景点的套票,买了一个套票就可以观看所有景点,不需要一个景点买一次票...我们重点介绍CAS单点登录的配置. 工具/原料 1.配置好JDK环境,否则不方 ...

  9. cas系列(一)--cas单点登录基本原理

    (这段时间打算做单点登录,因此研究了一些cas资料并作为一个系列记录下来,一来可能会帮助一些人,二来对我自己所学知识也是一个巩固.) 一.为什么要实现单点登录 随着信息化不断发展,企业的信息化过程是一 ...

随机推荐

  1. Merge Into

    Merge Into [dbo].[Student] S using [10.58.8.224\TEST].[TestDb].[dbo].[Student] T on S.ID=T.ID WHEN M ...

  2. js系列(10)js的运用(二)

        本节继续介绍在html页面中js的运用.   (1)数码时钟:(http://files.cnblogs.com/files/MenAngel/text05.zip) <!DOCTYPE ...

  3. javaweb回顾第二篇tomcat和web程序部署

    前言这篇主要说下关于tomcat中一些属性和web程序的简单部署,可能在实际开发有更好的部署方式,但是这也是一个基础. 1:tomcat 关于tomcat估计只要接触java的人都听过这个名字,那我们 ...

  4. 利用同一 ASP.NET 的多个代码框架

    2012 年,Microsoft 推出了两个添加到 ASP.NET 工具包的新框架:Web API 和 SignalR. 这两个框架为开发环境带来独特的开发方式,每个框架都有自身的独特之处: Web ...

  5. NXP LPC 状态可配置的定时器(SCT)

    状态可配置的定时器(SCT) 前言正在申请专利的状态可配置的定时器(SCT),是一个复杂的,但易于配置的定时器,它提供前所未有的灵活性,使工程师们在未来证明他们的设计,并减少进入市场的时间.在其最简单 ...

  6. 什么是automatic variable?

    看代码符号$?搞不清楚是什么?   看代码. $share = Get-WmiObject -Class Win32_Share -ComputerName $Server.name -Credent ...

  7. EWM ODO清理功能

    ERP OBD下传到EWM会自动产生拣货任务(通常做法),但如果EWM因库存不足或其它原因无法拣货时一般要差异确认,对ODO行项目进行0确认.但问题是零确认后EWM标准流程是无法回传ERP的. ERP ...

  8. JAVA的Proxy动态代理在自动化测试中的应用

    JAVA的动态代理,在MYBATIS中应用的很广,其核心就是写一个interface,但不写实现类,然后用动态代理来实例化并执行这个interface中的方法,话不多说,来看一个实现的例子: 1.先定 ...

  9. Sublime Text 3103 Crack 破解 注册码(亲测有效)

    随机复制下面的几四个注册码 粘贴到sublime text 3(Build 3103)注册框 就可以了! 第一个--first licence key : ====================== ...

  10. Codeforces Round #381 (Div. 1) A. Alyona and mex 构造

    A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...