profile updates

This commit is contained in:
AJ ONeal 2017-11-17 06:15:53 +00:00
parent 980895992a
commit ece06b8463
4 changed files with 137 additions and 52 deletions

View File

@ -149,7 +149,15 @@
<p>A (mostly) client-side authentication and authorization framework for decentralized peer-to-peer and federated networks.
</div>
<div class="row">
<a class="btn btn-primary" href="playground.html">Enter the OAuth3 Playground</a>
<div>
<h2>OAuth3 Test Bed</h2>
<!--
<a class="btn btn-primary" href="azp.html">Demo Authorized Party</a>
<a class="btn btn-primary" href="issuer.html">Demo Issuer</a>
-->
<a class="btn btn-primary" href="playground.html">Demo Authorized Party</a>
<a class="btn btn-primary" href="playground.html">Demo Issuer</a>
</div>
<div>
<h2>Private, Peer-to-Peer, Anonymous: Pick any two... at a time</h2>

View File

@ -94,6 +94,9 @@ $(function () {
// deprecated
'oauth3_authn': "Basic secure authentication"
, 'auth@oauth3.org': "Basic secure authentication"
, 'profile@oauth3.org': "Basic profile information"
, 'profile.email@oauth3.org': "Email address"
, 'profile.phone@oauth3.org': "Phone number"
, 'wallet': "Access to payments and subscriptions"
, 'bucket': "Access to file storage"
, 'db': "Access to app data"

View File

@ -4,27 +4,27 @@
window.ngOauth3App = angular.module('oauth3Playground', [ 'oauth3.org' ])
//window.ngOauth3App = angular.module('oauth3Playground', [ 'ui.router' ])
/*
ngOauth3App.config(function($stateProvider) {
var helloState = {
name: 'hello',
url: '/hello',
template: '<h3>hello world!</h3>'
}
ngOauth3App.config(function($stateProvider) {
var helloState = {
name: 'hello',
url: '/hello',
template: '<h3>hello world!</h3>'
}
var aboutState = {
name: 'about',
url: '/about',
template: '<h3>Its the UI-Router hello world app!</h3>'
}
var aboutState = {
name: 'about',
url: '/about',
template: '<h3>Its the UI-Router hello world app!</h3>'
}
$stateProvider.state(helloState);
$stateProvider.state(aboutState);
});
$stateProvider.state(helloState);
$stateProvider.state(aboutState);
});
*/
.controller('PlaygroundCtrl', [ '$timeout', 'azp@oauth3.org', function ($timeout, OAUTH3) {
.controller('PlaygroundCtrl', [ '$timeout', 'azp@oauth3.org', function ($timeout, OAUTH3) {
// NOTE: This OAUTH3 is the same as window.OAUTH3, but with angular's promise injected
// TODO: how to load more than one version of oauth3 on the page (i.e. a vanilla version without angular entaglement)
var vm = this;
var vm = this;
vm.framework = 'none';
vm.clientUri = OAUTH3.clientUri({ host: window.location.host });
@ -33,13 +33,18 @@
// map of things being debounced presently
vm.debouncing = {};
vm.defaults = { provider: vm.conf.provider_uri, directives: null };
vm.defaults.scopes = [
{ name: 'oauth3_authn', desc: "Basic secure authentication", checked: true }
//{ name: 'authn@oauth3.org', desc: "Basic secure authentication" }
, { name: 'photos@daplie.com', desc: "Access to photos" }
, { name: 'dns', desc: "DNS records (A/AAAA, TXT, SRV, MX, etc)" }
, { name: '*', desc: "FULL ACCOUNT ACCESS" }
];
vm.defaults.scopes = [
{ name: 'profile@oauth3.org', desc: "Basic profile information", checked: true }
, { name: 'oauth3_authn', desc: "Basic secure authentication", checked: true }
//{ name: 'authn@oauth3.org', desc: "Basic secure authentication" }
, { name: 'photos@daplie.com', desc: "Access to photos" }
, { name: 'profile@oauth3.org', desc: "Access to basic profile info such as username, display_name, etc" }
, { name: 'dns', desc: "DNS records (A/AAAA, TXT, SRV, MX, etc)" }
, { name: '*', desc: "FULL ACCOUNT ACCESS" }
//, 'auth@oauth3.org': "Basic secure authentication"
//, 'profile.email@oauth3.org': "Email address"
//, 'profile.phone@oauth3.org': "Phone number"
];
vm.form = {};
vm.form.id = 'coolaj86@gmail.com';
@ -420,6 +425,44 @@
vm.session = session;
});
};
vm.urls.profile = {};
vm.api.urls.profile_get = function () {
if (!vm.directives || !vm.accessToken) { return; }
vm.urls.profile_get = OAUTH3.urls.accounts.get(vm.directives, vm.ropSession);
};
vm.api.profile = {};
vm.api.profile_get = function () {
console.log('you tickled me!', vm.ropSession);
vm.api.urls.profile_get();
return OAUTH3.requests.accounts.get(vm.directives, vm.ropSession).then(function (resp) {
console.log('you tickled me twice!');
if (!resp.data) {
resp = { status: 0, data: resp };
}
vm.responses.profile_get = resp;
}, function (err) {
console.error('Could not get profile:');
console.error(err);
vm.error = err;
});
};
vm.api.profile_set = function () {
console.log('you tickled me!', vm.ropSession);
vm.api.urls.profile_set();
return OAUTH3.requests.accounts.set(vm.directives, vm.ropSession).then(function (resp) {
console.log('you tickled me twice!');
if (!resp.data) {
resp = { status: 0, data: resp };
}
vm.responses.profile_set = resp;
}, function (err) {
console.error('Could not set profile:');
console.error(err);
vm.error = err;
});
};
vm.api.authz = {};
vm.api.authz._grantsOpts = function () {
return vm.api.authz._grantsOpts_ = {
@ -456,35 +499,35 @@
vm.fn.updateScopes();
vm.apistr = '';
Object.keys(OAUTH3).forEach(function (key) {
var thingy = OAUTH3[key];
Object.keys(OAUTH3).forEach(function (key) {
var thingy = OAUTH3[key];
if ('_' === key[0] || -1 !== [ 'create', '_browser', '_defaultStorage', 'hooks', '_hooks', '_digest' ].indexOf(key)) {
if ('_' === key[0] || -1 !== [ 'create', '_browser', '_defaultStorage', 'hooks', '_hooks', '_digest' ].indexOf(key)) {
return;
}
if ('function' === typeof thingy) {
vm.apistr += thingy.toString().split(/\n/)[0].replace('function ', 'OAUTH3.' + key).replace(/\s+{\s*/, '') + '\n';
}
if ('function' === typeof thingy) {
vm.apistr += thingy.toString().split(/\n/)[0].replace('function ', 'OAUTH3.' + key).replace(/\s+{\s*/, '') + '\n';
}
if ('object' === typeof thingy) {
Object.keys(thingy).forEach(function (key2) {
var thingy2 = thingy[key2];
if ('function' === typeof thingy2) {
vm.apistr += thingy2.toString().split(/\n/)[0].replace('function ', 'OAUTH3.' + key + '.' + key2).replace(/\s+{\s*/, '') + '\n';
}
if ('object' === typeof thingy) {
Object.keys(thingy).forEach(function (key2) {
var thingy2 = thingy[key2];
if ('function' === typeof thingy2) {
vm.apistr += thingy2.toString().split(/\n/)[0].replace('function ', 'OAUTH3.' + key + '.' + key2).replace(/\s+{\s*/, '') + '\n';
}
if ('object' === typeof thingy2) {
Object.keys(thingy2).forEach(function (key3) {
var thingy3 = thingy2[key3];
if ('function' === typeof thingy3) {
vm.apistr += thingy3.toString().split(/\n/)[0].replace('function ', 'OAUTH3.' + key + '.' + key2 + '.' + key3).replace(/\s+{\s*/, '') + '\n';
}
});
}
if ('object' === typeof thingy2) {
Object.keys(thingy2).forEach(function (key3) {
var thingy3 = thingy2[key3];
if ('function' === typeof thingy3) {
vm.apistr += thingy3.toString().split(/\n/)[0].replace('function ', 'OAUTH3.' + key + '.' + key2 + '.' + key3).replace(/\s+{\s*/, '') + '\n';
}
});
}
});
}
});
} ] );
});
}
});
} ] );
}());

View File

@ -146,8 +146,11 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework"></span><span ng-if=
<pre><code>OAUTH3.discover("<span ng-bind="vm.form.provider"></span>", opts);</code></pre>
<pre ng-if="vm.urls.discovery"><code><span ng-bind="vm.urls.discovery"></span></code></pre>
<button ng-if="vm.directives" class="btn btn-default" ng-click="vm.fn.clearDirectives()">[X]</button>
<pre ng-if="vm.directives"><code><span ng-bind="vm.directives | json"></span></code></pre>
<div ng-if="vm.directives">
<button ng-if="vm.state.hideDirectives" class="btn btn-link" ng-click="vm.state.hideDirectives = !vm.state.hideDirectives">show directives</button>
<button ng-if="!vm.state.hideDirectives" class="btn btn-link" ng-click="vm.state.hideDirectives = !vm.state.hideDirectives">hide directives</button>
<pre ng-if="!vm.state.hideDirectives"><code><span ng-bind="vm.directives | json"></span></code></pre>
</div>
</div>
</div>
@ -215,7 +218,7 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework"></span><span ng-if=
(This is the URL of the iFrame that completes token refreshes. And it occurs over iFrame rather than API so that no server is required.)
</div>
<div class="col-md-9">
<button class="btn btn-default" ng-click="vm.api.refreshToken()" ng-disabled="!vm.directives || !vm.validated.provider">Open Logout Dialog</button>
<button class="btn btn-default" ng-click="vm.api.refreshToken()" ng-disabled="!vm.directives || !vm.validated.provider">Refresh Token</button>
<pre><code>OAUTH3.urls.refreshToken(directives, opts);</code></pre>
<pre ng-if="vm.urls.refreshToken"><code><span ng-bind="vm.urls.refreshToken"></span></code></pre>
@ -316,6 +319,34 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework"></span><span ng-if=
</div>
</div>
<div class="row" ng-if="vm.validated.provider">
<br>
<br>
<div class="col-md-3">
<strong>Profile</strong>
<br>
(this is the profile object)
</div>
<div class="col-md-9">
<button class="btn btn-default" ng-click="vm.api.profile_get()" ng-disabled="!vm.accessToken">Get Profile</button>
<pre><code><span ng-bind="vm.urls.profile_get.method"></span> <span ng-bind="vm.urls.profile_get.url"></span>
<span ng-if="vm.urls.profile_get.headers" ng-bind="vm.urls.profile_get.headers | json"></span>
<span ng-bind="vm.urls.profile_get.data | json"></span>
</code></pre>
<pre ng-if="!vm.responses.profile_get"><code> ...
</code></pre>
<pre ng-if="vm.responses.profile_get"><code><span ng-bind="vm.responses.profile_get.status"></span>
<span ng-if="vm.responses.profile_get.headers" ng-bind="vm.responses.profile_get.headers | json"></span>
<span ng-bind="vm.responses.profile_get.data | json"></span>
</code></pre>
</div>
</div>
<div class="row" ng-if="vm.validated.provider">
<br>
<br>
@ -346,7 +377,7 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework"></span><span ng-if=
<pre><code>OAUTH3.jwt.decode(token);</code></pre>
<textarea class="form-control" ng-model="vm.accessToken" ng-change="vm.api.jwt.decode()"></textarea>
<button class="btn btn-default" ng-click="vm.api.jwt.decode()" ng-disabled="!vm.refreshToken">Decode Access Token</button>
<button class="btn btn-default" ng-click="vm.api.jwt.decode()" ng-disabled="!vm.accessToken">Decode Access Token</button>
<textarea ng-if="vm.refreshToken" class="form-control" ng-model="vm.refreshToken" ng-change="vm.api.jwt.decodeRefresh()"></textarea>
<button ng-if="vm.refreshToken" class="btn btn-default" ng-click="vm.api.jwt.decodeRefresh()" ng-disabled="!vm.refreshToken">Decode Refresh Token</button>