Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.0.10 #36

Merged
merged 7 commits into from
Sep 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=5.3.0",
"php": ">=5.4.0",
"guzzlehttp/guzzle": "~5.0",
"ext-json": "*",
"adoy/oauth2": "~1.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-oauth/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $(document).ready(function() {
callbackURL: AUTH0_CALLBACK_URL
, responseType: 'code'
, authParams: {
scope: 'openid profile'
scope: 'openid'
}
});

Expand Down
2 changes: 1 addition & 1 deletion examples/basic-webapp/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $(document).ready(function() {
callbackURL: AUTH0_CALLBACK_URL
, responseType: 'code'
, authParams: {
scope: 'openid profile'
scope: 'openid'
}
});

Expand Down
20 changes: 20 additions & 0 deletions examples/link-users/composer.json
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": "[email protected]"
},
{
"name": "Germán Lena",
"email": "[email protected]"
}
]
}
10 changes: 10 additions & 0 deletions examples/link-users/config.php
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',
];
}
15 changes: 15 additions & 0 deletions examples/link-users/dotenv-loader.php
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
}








9 changes: 9 additions & 0 deletions examples/link-users/helpers.php
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;
}
37 changes: 37 additions & 0 deletions examples/link-users/index.php
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';
93 changes: 93 additions & 0 deletions examples/link-users/linkuser.php
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>
43 changes: 43 additions & 0 deletions examples/link-users/login.php
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>
95 changes: 95 additions & 0 deletions examples/link-users/public/app.css
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;
}
30 changes: 30 additions & 0 deletions examples/link-users/public/app.js
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'
}
});

});
});
Loading