Advertisement
Infra_HDC

ezproxyticket.php

Oct 15th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2.  
  3. // This PHP class can be used to generate EZproxy tickets.  See
  4. // ticket URLs.  When creating a new EZproxyTicket option,
  5. // the first parameter is the EZproxy server base
  6. // URL, the second is the shared secret that appears in user.txt/ezproxy.usr,
  7. // the third is a username to associate with the user, and the
  8. // last is optional and specifies any EZproxy groups the user
  9. // should be associated with.
  10. //
  11. // If you use a shared secret of shhh, then in user.txt/ezproxy.usr you
  12. // might use:
  13. //      ::Ticket
  14. //      MD5 shhhh
  15. //      /Ticket
  16. // to allow EZproxy to recognzie your tickets.
  17. //
  18. // Once the object is created, you can call its url method with a
  19. // database URL to generate a ticket URL.
  20.  
  21. class EZproxyTicket {
  22.   var $EZproxyStartingPointURL;
  23.  
  24.   function EZproxyTicket(
  25.     $EZproxyServerURL,
  26.     $secret,
  27.     $user,
  28.     $groups = "")
  29.   {
  30.     if (strcmp($secret, "") == 0) {
  31.       echo("EZproxyURLInit secret cannot be blank");
  32.       exit(1);
  33.     }
  34.  
  35.     $packet = '$u' . time();
  36.     if (strcmp($groups, "") != 0) {
  37.       $packet .=  '$g' . $groups;
  38.     }
  39.     $packet .= '$e';
  40.     $EZproxyTicket = urlencode(hash('sha512', $secret . $user . $packet, false) . $packet);
  41.     $this->EZproxyStartingPointURL = $EZproxyServerURL . "/login?user=" .
  42.       urlencode($user) . "&ticket=" . $EZproxyTicket;
  43.   }
  44.  
  45.   function URL($url)
  46.   {
  47.     return $this->EZproxyStartingPointURL . "&url=" . $url;
  48.   }
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement