diff --git a/index.html b/index.html index e57c50b..a2dccb8 100644 --- a/index.html +++ b/index.html @@ -149,7 +149,15 @@

A (mostly) client-side authentication and authorization framework for decentralized peer-to-peer and federated networks.

- Enter the OAuth3 Playground +
+

OAuth3 Test Bed

+ + Demo Authorized Party + Demo Issuer +

Private, Peer-to-Peer, Anonymous: Pick any two... at a time

diff --git a/js/issuer.js b/js/issuer.js index 3fe2419..f981466 100644 --- a/js/issuer.js +++ b/js/issuer.js @@ -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" diff --git a/js/playground.js b/js/playground.js index 1d51d5d..b594d64 100644 --- a/js/playground.js +++ b/js/playground.js @@ -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: '

hello world!

' - } + ngOauth3App.config(function($stateProvider) { + var helloState = { + name: 'hello', + url: '/hello', + template: '

hello world!

' + } - var aboutState = { - name: 'about', - url: '/about', - template: '

Its the UI-Router hello world app!

' - } + var aboutState = { + name: 'about', + url: '/about', + template: '

Its the UI-Router hello world app!

' + } - $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'; + } + }); + } - }); - } - }); - } ] ); + }); + } + }); + } ] ); }()); diff --git a/playground.html b/playground.html index 5e883fe..0c7a5b3 100644 --- a/playground.html +++ b/playground.html @@ -146,8 +146,11 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework">OAUTH3.discover("", opts);
- -
+
+ + +
+
@@ -215,7 +218,7 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework">
- +
OAUTH3.urls.refreshToken(directives, opts);
@@ -316,6 +319,34 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework">
+
+
+
+
+ Profile +
+ (this is the profile object) +
+
+ + + +
 
+
+
+
+ +
 ...
+
+ +

+
+
+
+ +
+
+


@@ -346,7 +377,7 @@ ng-if="'none' === vm.framework || 'jquery' === vm.framework">OAUTH3.jwt.decode(token); - +