Merge remote-tracking branch 'origin/v1.2'
This commit is contained in:
commit
9ac5c3ed89
116
oauth3.issuer.js
116
oauth3.issuer.js
|
@ -218,6 +218,7 @@ OAUTH3.urls.grants = function (directive, opts) {
|
|||
, session: opts.session
|
||||
};
|
||||
};
|
||||
//OAUTH3.urls.accessToken = function (directive, opts)
|
||||
OAUTH3.urls.clientToken = function (directive, opts) {
|
||||
var tokenDir = directive.access_token;
|
||||
if (!tokenDir) {
|
||||
|
@ -573,68 +574,85 @@ OAUTH3.authz.redirectWithToken = function (providerUri, session, clientParams, s
|
|||
};
|
||||
|
||||
OAUTH3.requests = {};
|
||||
//OAUTH3.accounts = {};
|
||||
OAUTH3.requests.accounts = {};
|
||||
OAUTH3.requests.accounts.update = function (directive, session, opts) {
|
||||
var dir = directive.update_account || {
|
||||
method: 'POST'
|
||||
, url: OAUTH3.url.normalize(directive.api) + '/api/issuer@oauth3.org/accounts/:accountId'
|
||||
OAUTH3.urls.accounts = {};
|
||||
OAUTH3.urls.accounts._ = function (directives, directive, session, opts) {
|
||||
opts = opts || {};
|
||||
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'
|
||||
};
|
||||
var url = dir.url
|
||||
.replace(/:accountId/, opts.accountId)
|
||||
.replace(/:accountId/, opts.accountId || '')
|
||||
.replace(/\/$/, '')
|
||||
;
|
||||
|
||||
return OAUTH3.request({
|
||||
method: dir.method || 'POST'
|
||||
, url: url
|
||||
return {
|
||||
url: url
|
||||
//, method: dir.method || 'POST'
|
||||
, session: session
|
||||
/*
|
||||
, headers: {
|
||||
'Authorization': (dir.bearer || 'Bearer') + ' ' + session.accessToken
|
||||
'Authorization': (dir.bearer || 'Bearer') + ' ' + (session.access_token || session.accessToken)
|
||||
}
|
||||
, json: {
|
||||
name: opts.name
|
||||
, comment: opts.comment
|
||||
, displayName: opts.displayName
|
||||
, 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 = {
|
||||
};
|
||||
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
|
||||
, comment: opts.comment
|
||||
, displayName: opts.displayName
|
||||
, priority: opts.priority
|
||||
};
|
||||
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
|
||||
// account = { nick, self: { comment, username } }
|
||||
// account = { name, comment, display_name, priority }
|
||||
account: {
|
||||
nick: account.display_name
|
||||
, name: account.name
|
||||
, comment: account.comment
|
||||
, display_name: account.display_name
|
||||
, priority: account.priority
|
||||
, self: {
|
||||
nick: account.display_name
|
||||
, name: account.name
|
||||
, comment: account.comment
|
||||
, display_name: account.display_name
|
||||
, priority: account.priority
|
||||
}
|
||||
}
|
||||
, logins: [
|
||||
{
|
||||
token: session.access_token
|
||||
}
|
||||
]
|
||||
credentials: credentials
|
||||
, profile: profile
|
||||
// 'account' is deprecated in favor of 'profile'
|
||||
, account: profile
|
||||
// 'logins' is deprecated in favor of 'credentials'
|
||||
, logins: credentials
|
||||
};
|
||||
|
||||
return OAUTH3.request({
|
||||
method: dir.method || 'POST'
|
||||
, url: dir.url
|
||||
, session: session
|
||||
, data: data
|
||||
});
|
||||
return urlObj;
|
||||
};
|
||||
OAUTH3.requests.accounts.get = function (directives, session) {
|
||||
var urlObj = OAUTH3.urls.accounts.get(directives, session);
|
||||
return OAUTH3.request(urlObj);
|
||||
};
|
||||
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 = {
|
||||
|
|
Loading…
Reference in New Issue