Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added authentication through EZproxy

  • Loading branch information...
commit 11f12f2567085e715b8aa68bf43a3495603cc06e 1 parent f5c978d
@K-Felk K-Felk authored
Showing with 49 additions and 0 deletions.
  1. +15 −0 display.php
  2. +34 −0 login.php
View
15 display.php
@@ -1,7 +1,22 @@
+<?
+session_start();
+if (!isset($_SESSION['username'])) {
+ header("Location: https://login.ezproxy.gvsu.edu/login?url=https://login.ezproxy.gvsu.edu/userObject?service=getToken&returnURL=http://gvsulib.com/felkerk/360Link_Reset/login.php");
+
+} else {
+ $user = trim($_SESSION['username']);
+
+ if ($user != 'felkerk' && $user != 'simons') {
+ echo "You suck";
+ die;
+ }
+
+}
+?>
<!DOCTYPE html>
<html>
View
34 login.php
@@ -0,0 +1,34 @@
+<?php
+
+ // Generate your own secret key for $wskey
+
+// cURL function by Brice Stacey:
+// http://bricestacey.com/2009/07/21/Single-Sign-On-Authentication-Using-EZProxy-UserObjects.html
+
+$wskey = 'JHjkh234jkh423jkh423jkhjk423hjk423hjkh423jkhK23JHK423JKH4JK23HJK423HJK423HJK423H';
+$url = $_GET['token'] . '&service=getUserObject&wskey=' . $wskey;
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+curl_setopt($ch, CURLOPT_URL, $url);
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+$o = curl_exec($ch);
+curl_close($ch);
+
+$data = new SimpleXMLElement($o); // Parse the XML return
+
+$user = (string)$data->userDocument[0]->uid;
+session_start();
+
+// Put whatever session variables you set up in UserObject here
+// http://wcn.oclc.org/index.php/Populating_the_EZproxy_User_Object
+
+$_SESSION['username'] = $user;
+
+session_write_close(); // Make sure the session variable is written before the redirect
+
+$new_url = "http://gvsulib.com/felkerk/360Link_Reset/display.php"; // URL of the app you are signing into
+
+header('Location: ' . $new_url);
+
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.