-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from auth0/1.x.x-dev
Release 1.0.10
- Loading branch information
Showing
14 changed files
with
362 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "auth0/basic-webapp-sample", | ||
"description": "Basic sample for securing a WebApp with Auth0", | ||
"require": { | ||
"adoy/oauth2": "dev-master", | ||
"vlucas/phpdotenv": "1.1.1", | ||
"auth0/auth0-php": "~1.0" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Martin Gontovnikas", | ||
"email": "martin@gon.to" | ||
}, | ||
{ | ||
"name": "Germán Lena", | ||
"email": "german.lena@gmail.com" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
function getAuth0Config() { | ||
return [ | ||
'domain' => 'wptest.auth0.com', | ||
'client_id' => 'KNuydwEqwGsPNpxdAhACmOWDUmBEZsLn', | ||
'client_secret' => 'cQT57M1wIYvcW1Rr6lTGWitqlkBtYwsyYkHG-mhVKdxhXBATWDwM6tB0mJFJVWFv', | ||
'redirect_uri' => 'http://localhost:3000/index.php', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
// Read .env | ||
try { | ||
Dotenv::load(__DIR__); | ||
} catch(InvalidArgumentException $ex) { | ||
// Ignore if no dotenv | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
|
||
function dd() { | ||
echo "<pre>"; | ||
foreach(func_get_args() as $param) | ||
var_dump($param); | ||
exit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
require_once 'helpers.php'; | ||
require_once 'dotenv-loader.php'; | ||
|
||
$auth0_config = array( | ||
'domain' => getenv('AUTH0_DOMAIN'), | ||
'client_id' => getenv('AUTH0_CLIENT_ID'), | ||
'client_secret' => getenv('AUTH0_CLIENT_SECRET'), | ||
'redirect_uri' => getenv('AUTH0_CALLBACK_URL'), | ||
'persist_id_token' => true, | ||
); | ||
|
||
if (isset($_REQUEST['link'])) { | ||
$auth0_config['persist_user'] = false; | ||
$auth0_config['persist_id_token'] = false; | ||
$auth0_config['store'] = false; | ||
} | ||
|
||
$auth0Oauth = new \Auth0\SDK\Auth0($auth0_config); | ||
|
||
$userInfo = $auth0Oauth->getUser(); | ||
|
||
if (isset($_REQUEST['logout'])) { | ||
$auth0Oauth->logout(); | ||
session_destroy(); | ||
header("Location: /"); | ||
} | ||
|
||
if ($userInfo) { | ||
header("Location: /linkuser.php"); | ||
exit; | ||
} | ||
|
||
|
||
require 'login.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
require_once 'vendor/autoload.php'; | ||
require_once 'helpers.php'; | ||
require_once 'dotenv-loader.php'; | ||
|
||
use Auth0\SDK\Store\SessionStore; | ||
$store = new SessionStore(); | ||
$main_user = $store->get('user'); | ||
if (!$main_user) { | ||
header("Location: /linkuser.php"); | ||
exit; | ||
} | ||
|
||
$auth0_config = array( | ||
'domain' => getenv('AUTH0_DOMAIN'), | ||
'client_id' => getenv('AUTH0_CLIENT_ID'), | ||
'client_secret' => getenv('AUTH0_CLIENT_SECRET'), | ||
'redirect_uri' => getenv('AUTH0_CALLBACK_URL'), | ||
'persist_user' => false, | ||
'persist_id_token' => false, | ||
'store' => false, | ||
); | ||
|
||
$auth0Oauth = new \Auth0\SDK\Auth0($auth0_config); | ||
|
||
$secondary_user = $auth0Oauth->getUser(); | ||
|
||
if ($secondary_user) { | ||
|
||
$app_token = getenv('AUTH0_APPTOKEN'); | ||
$domain = getenv('AUTH0_DOMAIN'); | ||
|
||
echo '<pre>'; | ||
|
||
echo "Main user: " . $main_user["user_id"] . "\n"; | ||
echo "Main user: " . $secondary_user["user_id"] . "\n"; | ||
|
||
var_dump( | ||
\Auth0\SDK\API\ApiUsers::linkAccount($domain, $app_token, $main_user["user_id"], array( | ||
"provider" => $secondary_user["identities"][0]["provider"], | ||
"user_id" => $secondary_user["identities"][0]["user_id"] | ||
) ) | ||
); | ||
echo '</pre>'; | ||
exit; | ||
} | ||
|
||
|
||
?> | ||
|
||
<html> | ||
<head> | ||
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script> | ||
<script src="https://cdn.auth0.com/js/lock-7.min.js"></script> | ||
|
||
<script type="text/javascript" src="//use.typekit.net/iws6ohy.js"></script> | ||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<!-- font awesome from BootstrapCDN --> | ||
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> | ||
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> | ||
|
||
<script> | ||
var AUTH0_CLIENT_ID = '<?php echo getenv("AUTH0_CLIENT_ID") ?>'; | ||
var AUTH0_DOMAIN = '<?php echo getenv("AUTH0_DOMAIN") ?>'; | ||
var AUTH0_LINKUSER_CALLBACK_URL = '<?php echo is_null(getenv("AUTH0_LINKUSER_CALLBACK_URL")) ? | ||
"http://localhost:3000/linkuser.php" : getenv("AUTH0_LINKUSER_CALLBACK_URL") ?>'; | ||
</script> | ||
|
||
|
||
<script src="/public/app.js"> </script> | ||
<link href="/public/app.css" rel="stylesheet"> | ||
|
||
|
||
|
||
</head> | ||
<body class="home"> | ||
<div class="container"> | ||
<div class="login-page clearfix"> | ||
|
||
<div class="login-box auth0-box before"> | ||
<img src="https://i.cloudup.com/StzWWrY34s.png" /> | ||
<h3>Auth0 Example</h3> | ||
<p>Link user</p> | ||
<a class="btn btn-primary btn-lg btn-link btn-block">Link</a> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<html> | ||
<head> | ||
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script> | ||
<script src="https://cdn.auth0.com/js/lock-7.min.js"></script> | ||
|
||
<script type="text/javascript" src="//use.typekit.net/iws6ohy.js"></script> | ||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<!-- font awesome from BootstrapCDN --> | ||
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> | ||
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> | ||
|
||
<script> | ||
var AUTH0_CLIENT_ID = '<?php echo getenv("AUTH0_CLIENT_ID") ?>'; | ||
var AUTH0_DOMAIN = '<?php echo getenv("AUTH0_DOMAIN") ?>'; | ||
var AUTH0_CALLBACK_URL = '<?php echo is_null(getenv("AUTH0_CALLBACK_URL")) ? | ||
"http://localhost:3000/index.php" : getenv("AUTH0_CALLBACK_URL") ?>'; | ||
</script> | ||
|
||
|
||
<script src="/public/app.js"> </script> | ||
<link href="/public/app.css" rel="stylesheet"> | ||
|
||
|
||
|
||
</head> | ||
<body class="home"> | ||
<div class="container"> | ||
<div class="login-page clearfix"> | ||
|
||
<div class="login-box auth0-box before"> | ||
<img src="https://i.cloudup.com/StzWWrY34s.png" /> | ||
<h3>Auth0 Example</h3> | ||
<p>Zero friction identity infrastructure, built for developers</p> | ||
<a class="btn btn-primary btn-lg btn-login btn-block">SignIn</a> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
body { | ||
font-family: "proxima-nova", sans-serif; | ||
text-align: center; | ||
font-size: 300%; | ||
font-weight: 100; | ||
} | ||
input[type=checkbox], | ||
input[type=radio] { | ||
position: absolute; | ||
opacity: 0; | ||
} | ||
input[type=checkbox] + label, | ||
input[type=radio] + label { | ||
display: inline-block; | ||
} | ||
input[type=checkbox] + label:before, | ||
input[type=radio] + label:before { | ||
content: ""; | ||
display: inline-block; | ||
vertical-align: -0.2em; | ||
width: 1em; | ||
height: 1em; | ||
border: 0.15em solid #0074d9; | ||
border-radius: 0.2em; | ||
margin-right: 0.3em; | ||
background-color: white; | ||
} | ||
input[type=radio] + label:before { | ||
border-radius: 50%; | ||
} | ||
input[type=radio]:checked + label:before, | ||
input[type=checkbox]:checked + label:before { | ||
background-color: #0074d9; | ||
box-shadow: inset 0 0 0 0.15em white; | ||
} | ||
input[type=radio]:focus + label:before, | ||
input[type=checkbox]:focus + label:before { | ||
outline: 0; | ||
} | ||
.btn { | ||
font-size: 140%; | ||
text-transform: uppercase; | ||
letter-spacing: 1px; | ||
border: 0; | ||
background-color: #16214D; | ||
color: white; | ||
} | ||
.btn:hover { | ||
background-color: #44C7F4; | ||
} | ||
.btn:focus { | ||
outline: none !important; | ||
} | ||
.btn.btn-lg { | ||
padding: 20px 30px; | ||
} | ||
.btn:disabled { | ||
background-color: #333; | ||
color: #666; | ||
} | ||
h1, | ||
h2, | ||
h3 { | ||
font-weight: 100; | ||
} | ||
#logo img { | ||
width: 300px; | ||
margin-bottom: 60px; | ||
} | ||
.home-description { | ||
font-weight: 100; | ||
margin: 100px 0; | ||
} | ||
h2 { | ||
margin-top: 30px; | ||
margin-bottom: 40px; | ||
font-size: 200%; | ||
} | ||
label { | ||
font-size: 100%; | ||
font-weight: 300; | ||
} | ||
.btn-next { | ||
margin-top: 30px; | ||
} | ||
.answer { | ||
width: 70%; | ||
margin: auto; | ||
text-align: left; | ||
padding-left: 10%; | ||
margin-bottom: 20px; | ||
} | ||
.login-page .login-box { | ||
padding: 100px 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
$(document).ready(function() { | ||
|
||
var lock = new Auth0Lock(AUTH0_CLIENT_ID, AUTH0_DOMAIN); | ||
|
||
$('.btn-login').click(function(e) { | ||
e.preventDefault(); | ||
|
||
lock.show({ | ||
callbackURL: AUTH0_CALLBACK_URL | ||
, responseType: 'code' | ||
, authParams: { | ||
scope: 'openid' | ||
} | ||
}); | ||
|
||
}); | ||
|
||
$('.btn-link').click(function(e) { | ||
e.preventDefault(); | ||
|
||
lock.show({ | ||
callbackURL: AUTH0_LINKUSER_CALLBACK_URL | ||
, responseType: 'code' | ||
, authParams: { | ||
scope: 'openid' | ||
} | ||
}); | ||
|
||
}); | ||
}); |
Oops, something went wrong.