Support Auth0.
[readifood.git] / lib / auth0.php
diff --git a/lib/auth0.php b/lib/auth0.php
new file mode 100644 (file)
index 0000000..96412f2
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+  use Auth0\SDK\Auth0;
+
+  $dotenv = new Dotenv\Dotenv($root);
+  $dotenv->load();
+
+  $AUTH0_AUDIENCE = getenv('AUTH0_AUDIENCE');
+  $AUTH0_CALLBACK_URL = getenv('AUTH0_CALLBACK_URL');
+  $AUTH0_CLIENT_ID = getenv('AUTH0_CLIENT_ID');
+  $AUTH0_CLIENT_SECRET = getenv('AUTH0_CLIENT_SECRET');
+  $AUTH0_DOMAIN = getenv('AUTH0_DOMAIN');
+  $AUTH0_LOGOUT_CALLBACK_URL = getenv('AUTH0_LOGOUT_CALLBACK_URL');
+
+  if (getenv("MEMCACHED")) {
+    ini_set("session.save_handler", "memcached");
+    ini_set("session.save_path", getenv("MEMCACHED"));
+  }
+
+  $auth0 = new Auth0([
+    'domain' => $AUTH0_DOMAIN,
+    'client_id' => $AUTH0_CLIENT_ID,
+    'client_secret' => $AUTH0_CLIENT_SECRET,
+    'redirect_uri' => $AUTH0_CALLBACK_URL,
+    'audience' => $AUTH0_AUDIENCE,
+    'scope' => 'openid profile',
+    'persist_id_token' => true,
+    'persist_access_token' => true,
+    'persist_refresh_token' => true,
+    'state_handler' => false
+  ]);
+
+?>