update docs and ng api
This commit is contained in:
parent
ee631b97c7
commit
52675f84c7
16
README.md
16
README.md
|
@ -286,6 +286,18 @@ We've created an `Oauth3` service just for you:
|
||||||
<script src="assets/org.oauth3/oauth3.ng.js"></script>
|
<script src="assets/org.oauth3/oauth3.ng.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Require the module as 'oauth3.org'
|
||||||
|
var app = angular.module('myAppName', [ 'ui.router', 'oauth3.org' ]);
|
||||||
|
|
||||||
|
// Require services and other submodules in the form {modulename}@oauth3.org
|
||||||
|
app.controller('authCtrl', [ '$scope', 'azp@oauth3.org', function ($scope, Oauth3) { /* ... */ } ]);
|
||||||
|
|
||||||
|
// For backwards compatibility with older angular applications that rely on string-name introspection
|
||||||
|
// you can also use the camel case version of the names in the format {Modulename}Oauth3
|
||||||
|
app.controller('authCtrl', function ($scope, AzpOauth3) { /* ... */ });
|
||||||
|
```
|
||||||
|
|
||||||
You can include that in addition to the standard file or,
|
You can include that in addition to the standard file or,
|
||||||
if you don't want an extra request, just paste it into your `app.js`.
|
if you don't want an extra request, just paste it into your `app.js`.
|
||||||
|
|
||||||
|
@ -300,8 +312,8 @@ oauth3 = OAUTH3.create(location); // takes a location object,
|
||||||
// to create the Client URI (your app's id)
|
// to create the Client URI (your app's id)
|
||||||
// and save it to an internal state
|
// and save it to an internal state
|
||||||
|
|
||||||
promise = oauth3.init(location); // set and fetch your own site/app's configuration details
|
promise = oauth3.init(opts); // set and fetch your own site/app's configuration details
|
||||||
// promises your site's config
|
// promises your site's config // opts = { location, session, issuer, audience }
|
||||||
|
|
||||||
promise = oauth3.setIdentityProvider(url); // changes the Identity Provider URI (the site you're logging into),
|
promise = oauth3.setIdentityProvider(url); // changes the Identity Provider URI (the site you're logging into),
|
||||||
// promises the provider's config // gets the config for that site (from their .well-known/oauth3),
|
// promises the provider's config // gets the config for that site (from their .well-known/oauth3),
|
||||||
|
|
|
@ -1097,7 +1097,16 @@
|
||||||
//, _resourceProviderMap: null // map between xyz.com and org.oauth3.domains
|
//, _resourceProviderMap: null // map between xyz.com and org.oauth3.domains
|
||||||
, _init: function (location, opts) {
|
, _init: function (location, opts) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (location) {
|
if (!opts) {
|
||||||
|
opts = location;
|
||||||
|
}
|
||||||
|
if (location && location.location) {
|
||||||
|
location = location.location;
|
||||||
|
}
|
||||||
|
if (opts && opts.location) {
|
||||||
|
me._clientUri = OAUTH3.clientUri(opts.location);
|
||||||
|
}
|
||||||
|
if (location && (location.host || location.hostname)) {
|
||||||
me._clientUri = OAUTH3.clientUri(location);
|
me._clientUri = OAUTH3.clientUri(location);
|
||||||
}
|
}
|
||||||
if (opts) {
|
if (opts) {
|
||||||
|
@ -1105,11 +1114,11 @@
|
||||||
me._identityProviderUri = opts.providerUri;
|
me._identityProviderUri = opts.providerUri;
|
||||||
me._resourceProviderUri = opts.providerUri;
|
me._resourceProviderUri = opts.providerUri;
|
||||||
}
|
}
|
||||||
if (opts.identityProviderUri) {
|
if (opts.issuer || opts.identityProviderUri) {
|
||||||
me._identityProviderUri = opts.identityProviderUri;
|
me._identityProviderUri = opts.issuer || opts.identityProviderUri;
|
||||||
}
|
}
|
||||||
if (opts.resourceProviderUri) {
|
if (opts.audience || opts.resourceProviderUri) {
|
||||||
me._resourceProviderUri = opts.resourceProviderUri;
|
me._resourceProviderUri = opts.audience || opts.resourceProviderUri;
|
||||||
}
|
}
|
||||||
if (opts.session) {
|
if (opts.session) {
|
||||||
if (!me._identityProviderUri) {
|
if (!me._identityProviderUri) {
|
||||||
|
|
56
oauth3.ng.js
56
oauth3.ng.js
|
@ -1,38 +1,44 @@
|
||||||
;(function () {
|
;(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular
|
var modules = {
|
||||||
.module('org.oauth3', [])
|
azp: [
|
||||||
.service('Oauth3', [
|
|
||||||
'$timeout'
|
'$timeout'
|
||||||
, '$q'
|
, '$q'
|
||||||
, function Oauth3($timeout, $q) {
|
, function Oauth3($timeout, $q) {
|
||||||
|
|
||||||
var OAUTH3 = window.OAUTH3;
|
var OAUTH3 = window.OAUTH3;
|
||||||
|
|
||||||
// We need to make angular's $q appear to be a standard Promise/A+
|
// We need to make angular's $q appear to be a standard Promise/A+
|
||||||
// fortunately, this is pretty easy
|
// fortunately, this is pretty easy
|
||||||
function PromiseAngularQ(fn) {
|
function PromiseAngularQ(fn) {
|
||||||
var d = $q.defer();
|
var d = $q.defer();
|
||||||
|
|
||||||
//$timeout(function () {
|
//$timeout(function () {
|
||||||
fn(d.resolve, d.reject);
|
fn(d.resolve, d.reject);
|
||||||
//}, 0);
|
//}, 0);
|
||||||
|
|
||||||
//this.then = d.promise.then;
|
//this.then = d.promise.then;
|
||||||
//this.catch = d.promise.catch;
|
//this.catch = d.promise.catch;
|
||||||
return d.promise;
|
return d.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
//PromiseAngularQ.create = PromiseAngularQ;
|
||||||
|
PromiseAngularQ.resolve = $q.when;
|
||||||
|
PromiseAngularQ.reject = $q.reject;
|
||||||
|
PromiseAngularQ.all = $q.all;
|
||||||
|
|
||||||
|
OAUTH3.PromiseA = PromiseAngularQ;
|
||||||
|
|
||||||
|
window.ngOauth3 = OAUTH3;
|
||||||
|
|
||||||
|
return OAUTH3;
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
//PromiseAngularQ.create = PromiseAngularQ;
|
angular
|
||||||
PromiseAngularQ.resolve = $q.when;
|
.module('oauth3.org', [])
|
||||||
PromiseAngularQ.reject = $q.reject;
|
.service('azp@oauth3.org', modules.azp);
|
||||||
PromiseAngularQ.all = $q.all;
|
.service('AzpOauth3', modules.azp);
|
||||||
|
|
||||||
OAUTH3.PromiseA = PromiseAngularQ;
|
|
||||||
|
|
||||||
window.ngOauth3 = OAUTH3;
|
|
||||||
|
|
||||||
return OAUTH3;
|
|
||||||
}]);
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in New Issue