zoukankan      html  css  js  c++  java
  • dotnet cas client 实现单点登录,登出问题记录

    单点登录功能实现,用到了cas,关于cas的详细介绍: https://apereo.github.io/cas/5.3.x/planning/Architecture.html

    在项目使用时,服务端使用了基于JAVA CAS的服务端,

    客户端使用asp.net,在asp.net中使用非常简单,github已有cas的.net 的 client ,链接:https://github.com/apereo/dotnet-cas-client

    .net 端集成dotnetcasclient很简单,按照官方的实例如下

    (1)注册casClientConfig Section

    <configSections>
      <section name="casClientConfig"
               type="DotNetCasClient.Configuration.CasClientConfiguration, DotNetCasClient"/>
      <!-- Other custom sections here -->
    </configSections>

    (2)新增 casClientConfig

    <casClientConfig
      casServerLoginUrl="https://server.example.com/cas/login"
      casServerUrlPrefix="https://server.example.com/cas/"
      serverName="https://client.example.com:8443"
      notAuthorizedUrl="~/NotAuthorized.aspx"
      cookiesRequiredUrl="~/CookiesRequired.aspx"
      redirectAfterValidation="true"
      renew="false"
      singleSignOut="true"
      ticketValidatorName="Cas20"
      serviceTicketManager="CacheServiceTicketManager" />

    (3)注册CasAuthenticationModule

    <system.web>
      <!-- Other system.web elements here -->
      <httpModules>
        <add name="DotNetCasClient"
             type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient"/>
        <!-- Other modules here -->
      </httpModules>
    </system.web>

    (4)配置asp.net 的form登录

    <system.web>
      <authentication mode="Forms">
        <forms
          loginUrl="https://server.example.com/cas/login"
          timeout="30"
          defaultUrl="~/Default.aspx"
          cookieless="UseCookies"
          slidingExpiration="true"
          path="/ApplicationName/" />
      </authentication>
      <!-- Other system.web elements here -->
    </system.web>

    以上的配置都可以在DotnetCasClient的github的README.md 看到,具体配置的解释也是包含的

    接下来就是发布网站到iis,就可以实现当前asp.net的站点的单点登录

    dotnetcasclient集成中的问题

    在集成中遇到了几个问题,这里做下备注

    (1)cas服务端使用https,asp.net应用端使用了http,浏览网站出现循环重定向的错误

    可以搜到很多类似问题的处理的文章,基本有三种种处理方法: 服务端和客户端使用相互信任的证书,修改sessionstate 和 修改源码。

    参考了文章: https://blog.csdn.net/alonesword/article/details/9564787  后,最终选择修改源码

    (2)asp.net应用端的单点登出功能异常

    在查阅cas的基本原理后,确定是应用端的认证在服务端登出后没有被销毁,关闭浏览器会被销毁,然而在实际应用中是不现实的,只能从服务端和客户端的配置入手

    1)确认服务端的配置,允许单点登出

    2)确认了客户端的配置,允许单点登出

    官方signout的配置介绍: https://apereo.github.io/cas/development/installation/Logout-Single-Signout.html#single-logout-slo

    然而,依然没有解决

    最终只能跟踪dotnetclient的源码,经过调试发现,服务端登出,本地应用没有登出请求的通知。

    最后发现由于是测试环境未分配正式域名,而测试和配置都是使用了域名进行验证,几台机器又未配置hosts导致。。。。

    最终修改hosts的配置,将服务端和应用端的域名分别配置在hosts,问题得以解决

  • 相关阅读:
    html5 标签
    开发中常见问题
    This Android SDK requires Andriod Developer Toolkit version 23.0.0 or above
    onActivityResult 要加判断
    expandlistview child 不可点击
    自定义dialog布局
    mediaPlayer 播放
    转载 收藏 listview判断是否在底部
    mediaPlayer
    org.apache.http.legacy.jar 兼容
  • 原文地址:https://www.cnblogs.com/dpwow/p/10648704.html
Copyright © 2011-2022 走看看