Infra_HDC icon

ezproxyticket.php

Infra_HDC | PRO | 10/15/19 07:01:55 AM UTC | 0 ⭐ | 919 👁️ | Never ⏰ | []
PHP |

1.43 KB

|

None

|

0 👍

/

0 👎

<?php
 
// This PHP class can be used to generate EZproxy tickets.  See
// ticket URLs.  When creating a new EZproxyTicket option,
// the first parameter is the EZproxy server base
// URL, the second is the shared secret that appears in user.txt/ezproxy.usr,
// the third is a username to associate with the user, and the
// last is optional and specifies any EZproxy groups the user
// should be associated with.
//
// If you use a shared secret of shhh, then in user.txt/ezproxy.usr you
// might use:
//      ::Ticket
//      MD5 shhhh
//      /Ticket
// to allow EZproxy to recognzie your tickets.
//
// Once the object is created, you can call its url method with a
// database URL to generate a ticket URL.
 
class EZproxyTicket {
  var $EZproxyStartingPointURL;
 
  function EZproxyTicket(
    $EZproxyServerURL,
    $secret,
    $user,
    $groups = "")
  {
    if (strcmp($secret, "") == 0) {
      echo("EZproxyURLInit secret cannot be blank");
      exit(1);
    }
 
    $packet = '$u' . time();
    if (strcmp($groups, "") != 0) {
      $packet .=  '$g' . $groups;
    }
    $packet .= '$e';
    $EZproxyTicket = urlencode(hash('sha512', $secret . $user . $packet, false) . $packet);
    $this->EZproxyStartingPointURL = $EZproxyServerURL . "/login?user=" .
      urlencode($user) . "&ticket=" . $EZproxyTicket;
  }
 
  function URL($url)
  {
    return $this->EZproxyStartingPointURL . "&url=" . $url;
  }
}
?>

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎