add oauth3
This commit is contained in:
parent
5455b16ec7
commit
0ad5017ac9
|
@ -0,0 +1 @@
|
||||||
|
../assets/oauth3.org/.well-known/oauth3
|
|
@ -24,6 +24,11 @@
|
||||||
<!-- Lodash -->
|
<!-- Lodash -->
|
||||||
<script src="/js/lib/lodash/lodash.min.js" charset="utf-8"></script>
|
<script src="/js/lib/lodash/lodash.min.js" charset="utf-8"></script>
|
||||||
<script src="/js/lib/lodash/lodash.underscore.min.js" charset="utf-8"></script>
|
<script src="/js/lib/lodash/lodash.underscore.min.js" charset="utf-8"></script>
|
||||||
|
<!-- Daplie Modules -->
|
||||||
|
<script src="/assets/oauth3.org/oauth3.core.js" charset="utf-8"></script>
|
||||||
|
<script src="/assets/oauth3.org/oauth3.dns.js" charset="utf-8"></script>
|
||||||
|
<script src="/assets/oauth3.org/oauth3.domains.js" charset="utf-8"></script>
|
||||||
|
<script src="/js/www@daplie.com.js" charset="utf-8"></script>
|
||||||
<!-- Angular Modules -->
|
<!-- Angular Modules -->
|
||||||
<script src="/js/lib/angular/angular.min.js" charset="utf-8"></script>
|
<script src="/js/lib/angular/angular.min.js" charset="utf-8"></script>
|
||||||
<script src="/js/lib/angular/angular-local-storage.js" charset="utf-8"></script>
|
<script src="/js/lib/angular/angular-local-storage.js" charset="utf-8"></script>
|
||||||
|
@ -31,6 +36,7 @@
|
||||||
<!-- Core Files -->
|
<!-- Core Files -->
|
||||||
<script src="/js/app.js" charset="utf-8"></script>
|
<script src="/js/app.js" charset="utf-8"></script>
|
||||||
<!-- Services -->
|
<!-- Services -->
|
||||||
|
<script src="/assets/oauth3.org/oauth3.ng.js" charset="utf-8"></script>
|
||||||
<script src="/js/services/contacts.js" charset="utf-8"></script>
|
<script src="/js/services/contacts.js" charset="utf-8"></script>
|
||||||
<script src="/js/services/auth.js" charset="utf-8"></script>
|
<script src="/js/services/auth.js" charset="utf-8"></script>
|
||||||
<!-- Controllers -->
|
<!-- Controllers -->
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mkdir -p assets
|
||||||
|
git clone git@git.daplie.com:OAuth3/oauth3.js.git assets/oauth3.org
|
||||||
|
pushd assets/oauth3.org
|
||||||
|
git checkout v1.1
|
||||||
|
popd
|
|
@ -1,4 +1,4 @@
|
||||||
var app = angular.module('launchpad', ['ui.router', 'LocalStorageModule']);
|
var app = angular.module('launchpad', ['oauth3.org', 'ui.router', 'LocalStorageModule']);
|
||||||
var redirectedURL;
|
var redirectedURL;
|
||||||
|
|
||||||
app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', function($stateProvider, $urlRouterProvider, localStorageServiceProvider){
|
app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', function($stateProvider, $urlRouterProvider, localStorageServiceProvider){
|
||||||
|
|
|
@ -1,15 +1,118 @@
|
||||||
app.controller('SignInController', ['$scope', 'Auth', '$location', 'localStorageService', '$rootScope', function ($scope, Auth, $location, localStorageService, $rootScope) {
|
app.controller('SignInController', [
|
||||||
|
'$scope', '$timeout', 'Auth', '$location', 'localStorageService', '$rootScope', 'azp@oauth3.org'
|
||||||
|
, function ($scope, $timeout, Auth, $location, localStorageService, $rootScope, Oauth3) {
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
|
vm.independentIssuer = false;
|
||||||
|
vm.oauth3 = Oauth3.oauth3 = Oauth3.oauth3 || Oauth3.create(location);
|
||||||
|
vm.timers = {};
|
||||||
|
vm.defaultIssuer = 'provider.' + location.host.replace(/^cloud\./, '');
|
||||||
|
|
||||||
|
vm.toggleAdvanced = function () {
|
||||||
|
vm.independentIssuer = !vm.independentIssuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm._setSubject = function (subject) {
|
||||||
|
vm.currentSubject = vm.newSubject;
|
||||||
|
subject = subject || vm.newSubject;
|
||||||
|
var issuer = subject.replace(/.*@/, '');
|
||||||
|
if (vm.independentIssuer) {
|
||||||
|
return $timeout(function () { return; }, 0);
|
||||||
|
}
|
||||||
|
return Oauth3.discover(issuer, { client_uri: Oauth3.clientUri(location) }).then(function (deets) {
|
||||||
|
return vm._setIssuer(issuer);
|
||||||
|
}, function () {
|
||||||
|
// ignore error
|
||||||
|
});
|
||||||
|
};
|
||||||
|
vm.setSubject = function (subject) {
|
||||||
|
$timeout.cancel(vm.timers.subject);
|
||||||
|
vm.timers.subject = $timeout(function () {
|
||||||
|
vm._setSubject(subject);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
vm._setIssuer = function (url) {
|
||||||
|
vm.spinner = true;
|
||||||
|
url = (url || vm.newIssuer).replace(/.*@/, '');
|
||||||
|
if (!url) {
|
||||||
|
url = vm.defaultIssuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Oauth3.discover(url, { client_uri: Oauth3.clientUri(location) }).then(function (deets) {
|
||||||
|
console.log('discover', url);
|
||||||
|
console.log(deets);
|
||||||
|
vm.currentIssuer = url;
|
||||||
|
vm.issuerName = url;
|
||||||
|
|
||||||
|
return vm.oauth3.setIdentityProvider(url).then(function (deets) {
|
||||||
|
vm.oauth3.setResourceProvider(url);
|
||||||
|
vm.spinner = false;
|
||||||
|
// TODO add icon and name to directives
|
||||||
|
console.log(deets);
|
||||||
|
});
|
||||||
|
}, function () {
|
||||||
|
console.log('oauth3 timeout: No dice, no change');
|
||||||
|
vm.spinner = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
vm.setIssuer = function (url) {
|
||||||
|
$timeout.cancel(vm.timers.issuer);
|
||||||
|
vm.timers.issuer = $timeout(function () {
|
||||||
|
vm._setIssuer(url);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
vm.setAudience = function (url) {
|
||||||
|
url = url || vm.audienceUrl;
|
||||||
|
vm.audienceName = url;
|
||||||
|
vm.oauth3.setResourceProvider(url);
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.selectSession = function (session) {
|
||||||
|
vm.oauth3.init({
|
||||||
|
location: location
|
||||||
|
, issuer: vm.currentIssuer
|
||||||
|
, audience: vm.currentIssuer
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.oauth3.sessions = vm.oauth3.sessions || [];
|
||||||
|
vm.instaauth = function () {
|
||||||
|
return vm._setSubject().then(function () {
|
||||||
|
return vm._setIssuer().then(function () {
|
||||||
|
return vm.auth();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
vm.auth = function () {
|
||||||
|
var subject = vm.currentSubject;
|
||||||
|
var issuer = vm.issuerName;
|
||||||
|
vm.oauth3.authenticate({
|
||||||
|
subject: subject
|
||||||
|
, scope: [ 'domains@oauth3.org', 'domains', 'dns@oauth3.org', 'dns', 'www@daplie.com' ]
|
||||||
|
}).then(function (session) {
|
||||||
|
console.log('session', session);
|
||||||
|
vm.hasSession = session;
|
||||||
|
session.subject = subject;
|
||||||
|
session.issuer = issuer;
|
||||||
|
vm.oauth3.sessions.push(session);
|
||||||
|
}, function (err) {
|
||||||
|
console.log('auth error');
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.newIssuer = vm.defaultIssuer;
|
||||||
|
vm.setIssuer(vm.defaultIssuer);
|
||||||
|
|
||||||
vm.signIn = function () {
|
vm.signIn = function () {
|
||||||
|
vm.auth().then(function () {
|
||||||
var userInfo = {
|
var userInfo = {
|
||||||
email: vm.userAuthEmail,
|
email: vm.currentSubject,
|
||||||
name: 'Johnny Cash'
|
name: 'Johnny Cash'
|
||||||
};
|
};
|
||||||
Auth.setUser(userInfo);
|
Auth.setUser(userInfo);
|
||||||
var userAuthenticated = function() {
|
});
|
||||||
return localStorageService.set('userAuth', JSON.stringify(userInfo));
|
|
||||||
}();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -2,13 +2,26 @@
|
||||||
<form>
|
<form>
|
||||||
<h4 class="text-center">Sign in</h4>
|
<h4 class="text-center">Sign in</h4>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="exampleInputEmail1">Email address</label>
|
<label for="dap-address">Address</label>
|
||||||
<input type="email" class="form-control" placeholder="Email" ng-model="vm.userAuthEmail">
|
<button class="btn btn-link" ng-click="vm.toggleAdvanced()" ng-if="vm.independentIssuer">hide advanced</button>
|
||||||
|
<button class="btn btn-link" ng-click="vm.toggleAdvanced()" ng-if="!vm.independentIssuer">show advanced</button>
|
||||||
|
<input type="text" class="form-control" placeholder="Email" ng-model="vm.newSubject" ng-change="vm.setSubject()">
|
||||||
</div>
|
</div>
|
||||||
|
<div ng-if="vm.independentIssuer">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="exampleInputPassword1">Password</label>
|
<label for="dap-issuer">Issuer</label>
|
||||||
<input type="password" class="form-control" placeholder="Password" ng-model="vm.userAuthPassword">
|
<input type="text" class="form-control" placeholder="Issuer" ng-model="vm.newIssuer" ng-change="vm.setIssuer()">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default" ng-click="vm.signIn()">Submit</button>
|
</div>
|
||||||
|
<button type="submit" class="btn btn-default" ng-click="vm.signIn()">Login with <span ng-bind="vm.issuerName"></span></button>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div>
|
||||||
|
Demo: <button class="btn btn-link" ng-click="vm.independentIssuer = true; vm.newSubject = 'coolaj86@gmail.com'; vm.newIssuer = 'provider.aj.daplie.me'; vm.instaauth();">coolaj86@aj.daplie.me</button>
|
||||||
|
<button class="btn btn-link" ng-click="vm.independentIssuer = true; vm.newSubject = 'coolaj86@gmail.com'; vm.newIssuer = 'oauth3.org'; vm.instaauth();">coolaj86@oauth3.org</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in New Issue