updates and add setIdentityProvider and setResourceProvider

This commit is contained in:
AJ ONeal 2017-06-14 22:39:26 +00:00
parent 2bf75a7429
commit a3b038ffdc
1 changed files with 25 additions and 21 deletions

View File

@ -20,7 +20,7 @@ If you have no idea what you're doing
1. Create a folder for your project named after your app, such as `example.com/`
2. Inside of the folder `example.com/` a folder called `assets/`
3. Inside of the folder `example.com/assets` a folder called `org.oauth3/`
4. Download [oauth.js-v1.zip](https://git.daplie.com/OAuth3/oauth3.js/repository/archive.zip?ref=v1)
4. Download [oauth3.js-v1.zip](https://git.daplie.com/OAuth3/oauth3.js/repository/archive.zip?ref=v1)
5. Double-click to unzip the folder.
6. Copy the file `oauth3.core.js` into the folder `example.com/assets/org.oauth3/`
7. Copy the folder `well-known` into the folder `example.com/`
@ -61,7 +61,7 @@ var auth = OAUTH3.create(window.location); // use window.location to set Client
//
function onChangeProvider(_providerUri) {
// example https://oauth3.org
return auth.setProvider(providerUri);
return oauth3.setIdentityProvider(providerUri);
}
@ -69,7 +69,7 @@ function onChangeProvider(_providerUri) {
//
function onClickLogin() {
return auth.authenticate().then(function (session) {
return oauth3.authenticate().then(function (session) {
console.info('Authentication was Successful:');
console.log(session);
@ -80,7 +80,7 @@ function onClickLogin() {
//
console.info('Secure PPID (aka subject):', session.token.sub);
return auth.request({
return oauth3.request({
url: 'https://oauth3.org/api/org.oauth3.provider/inspect'
, session: session
}).then(function (resp) {
@ -102,7 +102,7 @@ function onClickLogin() {
//
function onClickLogout() {
return auth.logout().then(function () {
return oauth3.logout().then(function () {
localStorage.clear();
console.info('Logout was Successful');
@ -284,29 +284,33 @@ We include a small wrapper function of just a few lines in the bottom of `oauth3
which exposes a `create` method to make using the underlying library require typing fewer keystrokes.
```
auth = OAUTH3.create(location); // takes a location object, such as window.location
// to create the Client URI (your app's id)
// and save it to an internal state
oauth3 = OAUTH3.create(location); // takes a location object, such as window.location
// to create the Client URI (your app's id)
// and save it to an internal state
promise = auth.init(location); // set and fetch your own site/app's configuration details
promise = oauth3.init(location); // set and fetch your own site/app's configuration details
// promises your site's config
promise = auth.setProvider(url); // changes the Provider URI (the site you're logging into),
// promises the provider's config // gets the config for that site (from their .well-known/oauth3),
// and caches it in internal state as the default
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),
// and caches it in internal state as the default
promise = auth.authenticate(); // opens login window for the provider and returns a session
// (must be called after the setProvider promise has completed)
promise = oauth3.setResourceProvider(url); // changes the Resource Provider URI (the site you're getting stuff from)
promise = auth.authorize(permissions); // authenticates (if not authenticated) and opens a window to
// authorize a particular scope (contacts, photos, whatever)
promise = oauth3.setProvider(url); // changes the both Identity and Resource Provider URI together
promise = auth.request({ url, method, data }); // make an (authorized) request to a provider's resource
// (contacts, photos, whatever)
promise = oauth3.authenticate(); // opens login window for the provider and returns a session
// (must be called after the setIdentityProvider promise has completed)
promise = auth.logout(); // opens logout window for the provider
promise = oauth3.authorize(permissions); // authenticates (if not authenticated) and opens a window to
// authorize a particular scope (contacts, photos, whatever)
auth.session(); // returns the current session, if any
promise = oauth3.request({ url, method, data }); // make an (authorized) request to a provider's resource
// (contacts, photos, whatever)
promise = oauth3.logout(); // opens logout window for the provider
oauth3.session(); // returns the current session, if any
```
@ -437,7 +441,7 @@ Since we do not require the `protocol` to be specified, it is a URI
However, we do have a problem of disambiguation since a URI may look like a `path`:
1. https://example.com/api/org.oauth3.provider
2. example.com/api/org.oauth.provider/ (not unique)
2. example.com/api/org.oauth3.provider/ (not unique)
3. /api/org.oauth3.provider
4. api/org.oauth3.provider (not unique)