identity
Version:
Identity client
39 lines (33 loc) • 1.18 kB
JavaScript
exports.list = {
name: 'proxy',
description: 'proxies all request to the identity server',
inputs: { required : [], optional : [] },
outputExample: {},
route: {
'get': 'identity/:resource',
'put': 'identity/:resource',
'post': 'identity/:resource',
'delete': 'identity/:resource'
},
run: function(api, connection, next){
if(connection.type === 'web'){
var path = connection.rawConnection.req.url;
var options = connection.rawConnection.params.body;
var method = connection.rawConnection.req.method.toLowerCase();
var access_token = connection.session.access_token;
if(method === 'get'){
path = connection.rawConnection.parsedURL.pathname;
options = connection.rawConnection.params.query;
}
path = path.replace('/api/identity/', '');
api.identity.application('identity', access_token)[method](path, options, function(err, response){
connection.error = err;
connection.response = response;
next(connection, true);
})
}else{
connection.error = 'not supported';
next(connection, true);
}
}
};