studentenraad / kotnetlogin-extension

Kotnet Login Browser Extension
GNU General Public License v3.0
2 stars 2 forks source link

kuleuven-campusnet login doesn't work #7

Open hellobe2121 opened 8 years ago

hellobe2121 commented 8 years ago

In (some) KU Leuven residences, in the Kotnet-login URL, inst=kuleuven, is replaced by inst=kuleuven-campusnet. Automatic kotnet-login therefore didn't work anymore in version 2.0.4 (login continues but results in "error 211: ongeldige organisatie"). This was fixed in version 2.0.5. However, this broke automatic kotnet-login for locations where inst=kuleuven still is in place. Version 2.0.6 reversed the situation to the 2.0.4 situation.

The following replacement for the Kotnet-redirect script is WIP. It works in instances where inst=kuleuven-campusnet, but fails to redirect and login inst=kuleuven situations.

Original code:

    // Redirect to login/logout page when visiting netlogin on campusnet or kotnet
    if (document.location.href == 'http://pre-netlogin.kuleuven.be/' || document.location.href == 'http://prenetlogin.icts.kuleuven.be/' || document.location.href == 'https://netlogin.kuleuven.be/' || document.location.href == 'https://netlogin.kuleuven.be/campusnet/' || document.location.href == 'https://netlogin.kuleuven.be/cgi-bin/netlogout.pl' || document.location.href == 'http://netlogin.kuleuven.be/' || document.location.href == 'http://netlogin.kuleuven.be/campusnet/' || document.location.href == 'http://netlogin.kuleuven.be/cgi-bin/netlogout.pl') {
        // Redirect to login page of the institute in the settings
        if (locale == 'nl') {
            document.location.href = 'https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven&lang=nl';
        } else {
            document.location.href = 'https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven&lang=en';
        }
    }

Replacement code

    // Redirect to general netlogin-page
    if (document.location.href == 'http://pre-netlogin.kuleuven.be/' || document.location.href == 'http://prenetlogin.icts.kuleuven.be/' || document.location.href == 'https://netlogin.kuleuven.be/campusnet/' || document.location.href == 'https://netlogin.kuleuven.be/cgi-bin/netlogout.pl' || document.location.href == 'http://netlogin.kuleuven.be/campusnet/' || document.location.href == 'http://netlogin.kuleuven.be/cgi-bin/netlogout.pl') {
    document.location.href = 'https://netlogin.kuleuven.be';
    }

    // Redirect to correct login page when visiting netlogin on campusnet or kotnet
    if (document.location.href == 'https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven-campusnet&lang=nl&submit=Ga+verder+%2F+Continue' || document.location.href == 'https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven-campusnet&lang=en&submit=Ga+verder+%2F+Continue') {
        null
    }   
    else if (document.location.href == 'https://netlogin.kuleuven.be' || document.location.href == 'http://netlogin.kuleuven.be') {
        if (locale == 'nl') {
        document.location.href = 'https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven&lang=nl';
        } else {
        document.location.href = 'https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven&lang=en';
        }
    }

I'm not able to figure out what's wrong with the redirect for inst=kuleuven. I live in a residence where inst=kuleuven-campusnet is in place, so it is difficult to test out code.

vierbergenlars commented 8 years ago

inst=kuleuven network requests:

  1. GET http://gstatic.com/generate_204
  2. GET http://prenetlogin.icts.kuleuven.be
  3. GET https://netlogin.kuleuven.be/
  4. GET https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven&lang=nl&submit=Ga+verder+%2F+Continue
  5. POST https://netlogin.kuleuven.be/cgi-bin/netlogin.pl inst=kuleuven&lang=nl&uid=r0000000&pwd21187=XXXX&submit=Login

Interesting part of the response to request 3:

        <form action="https://netlogin.kuleuven.be/cgi-bin/wayf2.pl" method="get" name="wayf">
        <table width="100%"  border="0" cellspacing="0" cellpadding="5" class="layouttable">
            <tr>
                <td valign="top"><div align="right">Instelling / Institution:</div></td>
                <td>
                  <select name="inst" id="inst" size="2"> 
                     <option value="kuleuven" selected="selected">Associatie KU Leuven</option>
                     <option value="kotnetext">KotNet Extern</option>
                   </select>
                </td>
            </tr>
            <tr>
                <td valign="top"><div align="right">Taal / Language:</div></td>
                <td>
                  <input type="radio" name="lang" value="nl" checked="checked">Nederlands</input>
                  <input type="radio" name="lang" value="en">English</input>
                </td>
            </tr>
            <tr>
                <td colspan=2 align=center>
                  <input name="submit" type="submit" value="Ga verder / Continue" />
                </td>
            </tr>
        </table>
        </form> 

@eliasvandeun Can you check if something looks different for you? (I guess <option value="kuleuven" selected="selected"> will be replaced by <option value="kuleuven-campusnet" selected="selected">)

If this is the case, we can detect which redirect we need. It will always require a detour through http://netlogin.kuleuven.be though, we won't be able to skip from 2 to 4 like we do now

hellobe2121 commented 8 years ago

These are the network requests when surfing to http://netlogin.kuleuven.be knipsel

Answer to the second request (campusnet):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl"> 
<head> 
<title>Netwerk Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="Description" content="KU Leuven, " /> 
<meta name="Keywords" content="KU Leuven, Katholieke Universiteit Leuven, " /> 
<style type="text/css" media="screen, projection"> 
@import url(https://stijl.kuleuven.be/_c/subnav.css);
@import url(https://stijl.kuleuven.be/_c/nieuws.css);
/* embedded styles hier */
</style> 
<link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/main.css" title="default" media="screen, projection" /> 
<!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/IE.css" media="screen, projection" /><![endif]--> 
<link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/handheld.css" media="handheld" /> 
<link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/css/style.css" title="default" /> 
</head> 
<body> 
<div id="wrapper"> 
  <div id="header"> 
<h2 class="access">Taakbalk</h2> 
<ul id="access">        
        <li><a href="#mainnav" tabindex="1" accesskey="N">navigatie</a></li> 
        <li><a href="#subnav" tabindex="2" accesskey="S">subnavigatie</a></li> 
        <li><a href="#content" tabindex="3" accesskey="C">inhoud</a></li> 
</ul> 
<ul id="taskbar"> 
        <li class="home"><a href="http://www.kuleuven.be/kuleuven/" tabindex="4" id="top" name="top">home</a></li> 
        <li class="whoiswho"><a href="http://cwisdb.kuleuven.be/persdb-bin/persdb?lang=N&amp;oproep=vraag">wie is wie</a></li> 
        <li class="organigram"><a href="http://organigram.kuleuven.be/">organigram</a></li> 
        <li class="contact"><a href="http://www.kuleuven.be/kuleuven/contact.html">contact</a></li> 
        <li class="intranet"><a href="http://www.kuleuven.be/intranet/">intranet</a></li> 
        <li class="langselect"><a href="http://www.kuleuven.be/english/" title="Choose English">english</a></li> 
</ul> 
<a href="http://www.kuleuven.be/kuleuven/"><img id="logo" src="https://stijl.kuleuven.be/logo_kuleuven.png" width="160" height="53" alt="logo" title="KU Leuven - Home" /></a>
<form action="http://robot.kuleuven.be/index.cgi" method="post" id="searchform" title="zoekformulier" name="searchform"><label for="words">zoekterm: </label> 
<input tabindex="5" type="text" name="words" id="words" title="geef een zoekterm"/><input tabindex="6" type="image" class="magnifier" src="https://stijl.kuleuven.be/_i/icons/icon_magnifier.gif" alt="verstuur" title="zoek nu"/><input type="hidden" name="oproep" value="zoek" /> 
</form> 
</div><!-- end header --> 
<div id="subnav"> 
    <h2><a href="http://admin.kuleuven.be/icts">ICTS</a></h2>    
    <ul id="subnavlist"> 
    <li><a href="http://admin.kuleuven.be/icts/services">Dienstverlening voor de universiteit</a></li><li class="separator"> <br /> </li><li><a href="http://admin.kuleuven.be/icts/helpdesk">Helpdesk</a></li>    </ul> 
  </div> 

<div id="nieuws"> 
<div class="indekijker"> 
            <h3>Meer informatie</h3> 
        <ul>
          <li><a href="https://admin.kuleuven.be/icts/services/kotnet" target="_blank">KotNet algemeen</a></li>
          <li><a href="https://admin.kuleuven.be/icts/services/kotnet/gebruiksvoorwaarden" target="_blank">Gedragscode voor KotNet</a></li>
          <li><a href="http://status.kuleuven.be/kuleuvennet" target="_blank">Netwerk status</a></li>
          <li><a href="http://icts.kuleuven.be/help/" target="_blank">Helpdesk</a></li>
        </ul>
</div> 
<div class="thema"> 
            <h3>More information</h3> 
        <ul>
          <li><a href="http://ludit.kuleuven.be/internet/index_en.html" target="_blank">KotNet in general</a></li>
          <li><a href="http://ludit.kuleuven.be/internet/kotnet/voorwaarden_en.html" target="_blank">KotNet Use Policy</a></li>
          <li><a href="http://status.kuleuven.be/kuleuvennet" target="_blank">Network status</a></li>
          <li><a href="http://icts.kuleuven.be/help/index_en.html" target="_blank">Helpdesk</a></li>
        </ul>
</div> 
</div>    

  <div id="contentwrapper"> 
    <div id="content"> 
      <!-- content starts here --> 
                  <!--<div id="navbar"><span style="display: none">Navigatiebalk: </span><a href="/">Home</a> &gt; <a href="/leeg/">Leeg</a></div> -->

<h1>KotNet/CampusNet</h1>
<h2>Netwerk Login</h2>
        <div class="associatie_logo">
                  <img src="/images/associatie_logo.gif" width="44" height="62" border="0"/>
        </div>

        Via deze login krijg je automatisch toegang tot het Internet en KotNet/CampusNet.
        <br/>
        <br/>
        <div align="center">
        <form action="/cgi-bin/netlogin.pl" method="post" name="netlogin">
          <table width="100%"  border="0" cellspacing="0" cellpadding="5" class="layouttable">
            <tr>
              <td colspan="2">
                <input type="hidden" name="inst" value="kuleuven-campusnet" /> 
                <input type="hidden" name="lang" value="nl" /> 
              <div align="center">
                <img src="/images/kuleuven-campusnet.gif" border="0" alt="KU Leuven CampusNet" />
              </div>
              </td>
            </tr>
            <tr>
              <td><div align="right">Intranet userid:</div></td>
              <td><input type="text" size="20" maxlength="50" name="uid" id="uid" class="formField" /></td>
            </tr>
            <tr>
              <td><div align="right">Wachtwoord:</div></td>
              <td><input type="password" size="20" maxlength="50" name="pwd29710" class="formField" autocomplete="off"/></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="submit" name="submit" value="Login" /></td>
            </tr>
          </table>
        </form> 
        </div>

<script type="text/javascript">
  <!--
  document.getElementById("uid").focus();

  if (self != top) {
        top.location.href = self.location.href;
  }
  //-->
</script>

      <!-- content ends here --> 
    </div> 
  </div> 
  <!--end contentwrapper--> 
  <div id="footer"> 
     <p>Copyright &copy; KU Leuven | reacties op de inhoud: <a href="mailto:ICTS@kuleuven.be">ICTS</a><br /> 
      Realisatie: <a href="mailto:icts@kuleuven.be">ICTS</a>| <a href="http://www.kuleuven.be/kuleuven/disclaimer.html">Disclaimer</a> 
                  </p> 
  </div> 
</div> 

</body> 
</html> 

When surfing to https://netlogin.kuleuven.be, you're automatically redirected to https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven-campusnet&lang=nl&submit=Ga+verder+%2F+Continue