0

I have a project that redirect user to cas server and after user log in redirect it to my local (I'm using virtual host on IIS my.uk.ac.ir). Problem is that when it returns it doesnt return attribute. my project is on .net4.5.2 and using tls12

this is the original project that I modified. https://github.com/casinthecloud/dotnet-cas-client-demo

this is the link to modified project: https://github.com/HamidRezaAshkiyan/dotnet-cas-client-demo my modification is on dev branch.

Here is my web.config:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="casClientConfig" type="DotNetCasClient.Configuration.CasClientConfiguration, DotNetCasClient"/>
  </configSections>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>
    <authentication mode="Forms">
      <forms name=".DotNetCasClientAuth" loginUrl="https://gate.uk.ac.ir" cookieless="UseCookies"/>
    </authentication>
    <httpModules>
      <add name="DotNetCasClient" type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient"/>
    </httpModules>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <remove name="DotNetCasClient"/>
      <add name="DotNetCasClient" type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient"/>
    </modules>
  </system.webServer>
  <casClientConfig casServerLoginUrl="https://gate.uk.ac.ir" casServerUrlPrefix="https://gate.uk.ac.ir" serverName="https://my.uk.ac.ir/" notAuthorizedUrl="~/NotAuthorized.aspx" cookiesRequiredUrl="~/CookiesRequired.aspx" redirectAfterValidation="true" gateway="false" renew="false" singleSignOut="true" ticketTimeTolerance="5000" ticketValidatorName="Cas10" proxyTicketManager="CacheProxyTicketManager" serviceTicketManager="CacheServiceTicketManager" gatewayStatusCookieName="CasGatewayStatus"/>
</configuration>

this is my index page where redirects after login:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="dotnet_cas_client_demo.secure.index" %>

<asp:Content ID="Content1" ContentPlaceHolderID="content" runat="server">

    <ul class="nav nav-tabs">
        <li><a href="/index.aspx">Call the /index.aspx page</a></li>
        <li class="active"><a href="/secure/index.aspx">You are on the /secure/index.aspx page</a></li>
        <!-- #### change with your own CAS server and your host name #### -->
        <li><a href="http://gate.uk.ac.ir/logout?service=https://my.uk.ac.ir/">Call the CAS logout</a></li>
    </ul>
    <h3>
        <p>username: <span id="username" runat="server" /></p>
        
        <p>AttributeCount: <span id="attributes" runat="server" /></p>
        <p>Attribute: <span id="attribute" runat="server" /></p>
        

    </h3>

</asp:Content>

this is the backend code:

using System;

namespace dotnet_cas_client_demo.secure
{
    public partial class index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // get the current authenticated user
            username.InnerText = System.Web.HttpContext.Current.User.Identity.Name;

            attributes.InnerText = CasAuthentication.CurrentPrincipal.Assertion.Attributes.Count.ToString();
        }
    }
}

I'm not sure that the right way of getting the attributes or not.

I've tried this solution for java but not helped me. Cas no attributes come to client

there where similar problem on php and my coworkers solved it with cas protocol 3 and i saw similar on the answer above.

4

1 回答 1

0

经过大量谷歌搜索后,我发现该库不支持 cas 协议 3,并且我发现了另一个在 .net core 3 上运行并默认支持 3 的库: https ://github.com/akunzai/GSS.Authentication.CAS

它帮助我获得了属性。

Apereo 库正在支持协议 3。

于 2020-07-12T11:21:39.890 回答