Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 5ebc0b78426815f1ab2a8f66280efce57c937bfd @danielbeardsley danielbeardsley committed Jan 4, 2012
Showing with 58 additions and 0 deletions.
  1. +2 −0 README
  2. +56 −0 dozuki_sso.php
2 README
@@ -0,0 +1,2 @@
+== Dozuki Single Sign On ==
+
@@ -0,0 +1,56 @@
+<?php
+DozukiAuthentication::authenticate();
+
+class DozukiAuthentication {
+ public static function authenticate() {
+ $userInfo = $this->getUserInfo();
+ if (!$userInfo)
+ self::sendToLogin();
+
+ $params = array_merge($userInfo, array(
+ 't' = time()
+ ));
+
+ $destinationURL = self::$dozukiSite . '/Guide/remote_login?';
+
+ $query = http_build_query($params);
+ $hash = sha1($query . self::$secret);
+ $query .= "&hash=" . $hash;
+
+ http_redirect($destinationURL . $query);
+ }
+
+ // ========================================================
+ // Only Make Changes below this line
+ // ========================================================
+ protected static $dozukiSite = 'yoursitename.dozuki.com';
+ protected static $secret = 'abcdefghijklmnopqrstuvwxyz01234567890';
+
+ /**
+ * Change this function to return the specified info for the currently
+ * logged in user. If the current user is anonymous, this should return
+ * null.
+ */
+ protected static function getUserInfo() {
+ return array(
+ // A string that uniquely identifies the logged in user
+ // i.e. anything that doesn't change: (id, email, username)
+ 'userid' => '123456',
+ 'email' => 'user@example.com',
+ // A users's real name, if available
+ 'name' => 'First Last'
+ );
+ }
+
+ /**
+ * This function should redirect the user to your login page, or just render
+ * it directly.
+ */
+ protected static function sendToLogin() {
+ // Redirect the user to your login page.
+ // Or, just render the login page
+ }
+}
+
+DozukiAuthentication::authenticate();
+

0 comments on commit 5ebc0b7

Please sign in to comment.