Added contact offers.
[readifood.git] / lib / auth0.php
1 <?php
2
3   use Auth0\SDK\Auth0;
4
5   $dotenv = new Dotenv\Dotenv($root);
6   $dotenv->load();
7
8   $AUTH0_AUDIENCE = getenv('AUTH0_AUDIENCE');
9   $AUTH0_CALLBACK_URL = getenv('AUTH0_CALLBACK_URL');
10   $AUTH0_CLIENT_ID = getenv('AUTH0_CLIENT_ID');
11   $AUTH0_CLIENT_SECRET = getenv('AUTH0_CLIENT_SECRET');
12   $AUTH0_DOMAIN = getenv('AUTH0_DOMAIN');
13   $AUTH0_LOGOUT_CALLBACK_URL = getenv('AUTH0_LOGOUT_CALLBACK_URL');
14
15   if (getenv("MEMCACHED")) {
16     ini_set("session.save_handler", "memcached");
17     ini_set("session.save_path", getenv("MEMCACHED"));
18   }
19   else {
20     include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "SessionHandler.php")));
21     $session_handler = new \JL\SessionHandler();
22     $session_handler->setPDO(Propel::getConnection());
23     $session_handler->setDbTable('Session');
24     session_set_save_handler(
25       array($session_handler, 'open'),
26       array($session_handler, 'close'),
27       array($session_handler, 'read'),
28       array($session_handler, 'write'),
29       array($session_handler, 'destroy'),
30       array($session_handler, 'gc')
31     );
32     register_shutdown_function('session_write_close');
33   }
34
35   $auth0 = new Auth0([
36     'domain' => $AUTH0_DOMAIN,
37     'client_id' => $AUTH0_CLIENT_ID,
38     'client_secret' => $AUTH0_CLIENT_SECRET,
39     'redirect_uri' => $AUTH0_CALLBACK_URL,
40     'audience' => $AUTH0_AUDIENCE,
41     'scope' => 'openid profile',
42     'persist_id_token' => true,
43     'persist_access_token' => true,
44     'persist_refresh_token' => true,
45     'state_handler' => false
46   ]);
47
48 ?>