Merge remote-tracking branch 'origin/v1.2'
This commit is contained in:
commit
9ac5c3ed89
108
oauth3.issuer.js
108
oauth3.issuer.js
|
@ -218,6 +218,7 @@ OAUTH3.urls.grants = function (directive, opts) {
|
||||||
, session: opts.session
|
, session: opts.session
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
//OAUTH3.urls.accessToken = function (directive, opts)
|
||||||
OAUTH3.urls.clientToken = function (directive, opts) {
|
OAUTH3.urls.clientToken = function (directive, opts) {
|
||||||
var tokenDir = directive.access_token;
|
var tokenDir = directive.access_token;
|
||||||
if (!tokenDir) {
|
if (!tokenDir) {
|
||||||
|
@ -573,68 +574,85 @@ OAUTH3.authz.redirectWithToken = function (providerUri, session, clientParams, s
|
||||||
};
|
};
|
||||||
|
|
||||||
OAUTH3.requests = {};
|
OAUTH3.requests = {};
|
||||||
|
//OAUTH3.accounts = {};
|
||||||
OAUTH3.requests.accounts = {};
|
OAUTH3.requests.accounts = {};
|
||||||
OAUTH3.requests.accounts.update = function (directive, session, opts) {
|
OAUTH3.urls.accounts = {};
|
||||||
var dir = directive.update_account || {
|
OAUTH3.urls.accounts._ = function (directives, directive, session, opts) {
|
||||||
method: 'POST'
|
opts = opts || {};
|
||||||
, url: OAUTH3.url.normalize(directive.api) + '/api/issuer@oauth3.org/accounts/:accountId'
|
var dir = directive || {
|
||||||
|
//url: OAUTH3.url.normalize(directives.api) + '/api/issuer@oauth3.org/accounts/:accountId'
|
||||||
|
url: OAUTH3.url.normalize(directives.api) + '/api/issuer@oauth3.org/acl/profiles/:accountId'
|
||||||
|
//, method: 'GET'
|
||||||
, bearer: 'Bearer'
|
, bearer: 'Bearer'
|
||||||
};
|
};
|
||||||
var url = dir.url
|
var url = dir.url
|
||||||
.replace(/:accountId/, opts.accountId)
|
.replace(/:accountId/, opts.accountId || '')
|
||||||
|
.replace(/\/$/, '')
|
||||||
;
|
;
|
||||||
|
|
||||||
return OAUTH3.request({
|
return {
|
||||||
method: dir.method || 'POST'
|
url: url
|
||||||
, url: url
|
//, method: dir.method || 'POST'
|
||||||
|
, session: session
|
||||||
|
/*
|
||||||
, headers: {
|
, headers: {
|
||||||
'Authorization': (dir.bearer || 'Bearer') + ' ' + session.accessToken
|
'Authorization': (dir.bearer || 'Bearer') + ' ' + (session.access_token || session.accessToken)
|
||||||
}
|
}
|
||||||
, json: {
|
*/
|
||||||
|
};
|
||||||
|
};
|
||||||
|
OAUTH3.urls.accounts.get = function (directives, session) {
|
||||||
|
var urlObj = OAUTH3.urls.accounts._(directives, directives.account, session);
|
||||||
|
urlObj.method = (directives.account || { method: 'GET' }).method;
|
||||||
|
return urlObj;
|
||||||
|
};
|
||||||
|
OAUTH3.urls.accounts.update = function (directives, session, opts) {
|
||||||
|
var urlObj = OAUTH3.urls.accounts._(directives, directives.update_account, session, opts);
|
||||||
|
urlObj.method = (directives.update_account || { method: 'POST' }).method;
|
||||||
|
urlObj.json = {
|
||||||
name: opts.name
|
name: opts.name
|
||||||
, comment: opts.comment
|
, comment: opts.comment
|
||||||
, displayName: opts.displayName
|
, displayName: opts.displayName
|
||||||
, priority: opts.priority
|
, priority: opts.priority
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
OAUTH3.requests.accounts.create = function (directive, session, account) {
|
|
||||||
var dir = directive.create_account || {
|
|
||||||
method: 'POST'
|
|
||||||
, url: OAUTH3.url.normalize(directive.api) + '/api/issuer@oauth3.org/accounts'
|
|
||||||
, bearer: 'Bearer'
|
|
||||||
};
|
};
|
||||||
var data = {
|
return urlObj;
|
||||||
|
};
|
||||||
|
OAUTH3.urls.accounts.create = function (directives, session, account) {
|
||||||
|
var urlObj = OAUTH3.urls.accounts._(directives, directives.create_account, session);
|
||||||
|
var profile = {
|
||||||
|
nick: account.display_name
|
||||||
|
// "name" is unique and what would be reserved in a url {{name}}.issuer.org or issuer.org/users/{{name}}
|
||||||
|
, name: account.name
|
||||||
|
, comment: account.comment
|
||||||
|
, display_name: account.display_name
|
||||||
|
, priority: account.priority
|
||||||
|
};
|
||||||
|
var credentials = [ { token: session.access_token } ];
|
||||||
|
urlObj.method = (directives.create_account || { method: 'POST' }).method;
|
||||||
|
urlObj.json = {
|
||||||
// TODO fix the server to just use one scheme
|
// TODO fix the server to just use one scheme
|
||||||
// account = { nick, self: { comment, username } }
|
// account = { nick, self: { comment, username } }
|
||||||
// account = { name, comment, display_name, priority }
|
// account = { name, comment, display_name, priority }
|
||||||
account: {
|
credentials: credentials
|
||||||
nick: account.display_name
|
, profile: profile
|
||||||
, name: account.name
|
// 'account' is deprecated in favor of 'profile'
|
||||||
, comment: account.comment
|
, account: profile
|
||||||
, display_name: account.display_name
|
// 'logins' is deprecated in favor of 'credentials'
|
||||||
, priority: account.priority
|
, logins: credentials
|
||||||
, self: {
|
|
||||||
nick: account.display_name
|
|
||||||
, name: account.name
|
|
||||||
, comment: account.comment
|
|
||||||
, display_name: account.display_name
|
|
||||||
, priority: account.priority
|
|
||||||
}
|
|
||||||
}
|
|
||||||
, logins: [
|
|
||||||
{
|
|
||||||
token: session.access_token
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
return urlObj;
|
||||||
return OAUTH3.request({
|
};
|
||||||
method: dir.method || 'POST'
|
OAUTH3.requests.accounts.get = function (directives, session) {
|
||||||
, url: dir.url
|
var urlObj = OAUTH3.urls.accounts.get(directives, session);
|
||||||
, session: session
|
return OAUTH3.request(urlObj);
|
||||||
, data: data
|
};
|
||||||
});
|
OAUTH3.requests.accounts.update = function (directives, session, opts) {
|
||||||
|
var urlObj = OAUTH3.urls.accounts.update(directives, session, opts);
|
||||||
|
return OAUTH3.request(urlObj);
|
||||||
|
};
|
||||||
|
OAUTH3.requests.accounts.create = function (directive, session, account) {
|
||||||
|
var urlObj = OAUTH3.urls.accounts.create(directives, session, account);
|
||||||
|
return OAUTH3.request(urlObj);
|
||||||
};
|
};
|
||||||
|
|
||||||
OAUTH3.hooks.grants = {
|
OAUTH3.hooks.grants = {
|
||||||
|
|
Loading…
Reference in New Issue