New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

actionhero-oauth2-client

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

actionhero-oauth2-client - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

.npmignore

66

lib/actions/oauth.js

@@ -1,8 +0,6 @@

var request = require('request');
module.exports = {
name: 'oauth',
version: 2,
description: 'OAuth2',
inputs: { required: [], optional: ['code', 'error', 'access_token'] },
description: 'OAuth2 Client',
inputs: { required: ['code'], optional: ['error'] },
outputExample: {},

@@ -12,50 +10,16 @@ requireAuth: false,

var code = connection.params.code;
var access_token = connection.params.access_token;
if(code){
api.oauth2.oauth.AuthCode.getToken({
code: code,
redirect_uri: api.oauth2.redirect_url
}, function (error, result) {
if(error){
console.log('Access Token Error', error.message);
//Access not granted... back to login?! or error page...
connection.response.error = 'Bad Request'
next(connection, true);
}else{
access_token = api.oauth2.oauth.AccessToken.create(result).token.access_token;
//save access token to connection.id
api.cache.save(api.oauth2.action + ':token:' + access_token, connection.id);
request.get(api.oauth2.site + api.oauth2.userPath + '?access_token=' + access_token, {json:true}, function(error, msg, result){
if(error){
connection.response.error = error;
next(connection, false);
}else{
api.cache.save(api.oauth2.action + ':connection:' + connection.id, {token:access_token, user:result.user}, null, function(){
var res = connection.rawConnection.res;
res.writeHead(303, {Location: '/'});
res.end();
next(connection, false);
});
}
});
}
});
}else{
if(access_token){
//destroy Access token
api.cache.load(api.oauth2.action + ':token:' + access_token, function(err, connection_id){
api.cache.destroy(api.oauth2.action + ':connection:' + connection_id);
api.cache.destroy(api.oauth2.action + ':token:' + access_token);
});
}
next(connection, true);
}
api.oauth2.oauth.AuthCode.getToken({
code: code,
redirect_uri: api.oauth2.redirect_url
}, function (error, result) {
if(error){
api.oauth2.emit('unauthorized', api, connection, next);
}else{
connection.params.access_token = api.oauth2.oauth.AccessToken.create(result).token.access_token;
api.oauth2.emit('authorized', api, connection, next);
}
});
}
}
};
var OAuth2 = require('simple-oauth2');
var events = require('events');
var util = require('util');

@@ -12,12 +14,6 @@ var OAuth2Client = module.exports = function(config){

this.tokenPath = config.tokenPath || '/api/oauth/access_token';
this.userPath = config.userPath || '/api/user:info';
this.logoutPath = config.logoutPath || '/api/user:logout';
this.scope = config.scope | '';
this.action = config.action || 'oauth';
this.user_action = config.user_action || 'user';
this.logout_action = config.logout_action || 'logout';
this.client_site = config.client_site;
this.oauth = new OAuth2({

@@ -32,2 +28,3 @@ clientID: this.id,

this.initializer = function(api, next){

@@ -37,10 +34,7 @@

self.createOAuth2Action(api);
self.createUserAction(api);
self.createLogoutAction(api);
self.createPreProcessor(api);
self.createOAuth2Action(api);
//to rebuild the required and optional params for the dummy action...
api.params.buildPostVariables();
api.routes.routes.get.push({ path: 'user.js', action: self.user_action });
self.protocol = api.config.servers['web'].secure ? 'https' : 'http';

@@ -52,2 +46,5 @@ next();

util.inherits(OAuth2Client, events.EventEmitter);
OAuth2Client.prototype.redirectToLogin = function(connection){

@@ -58,4 +55,4 @@

if(!self.redirect_url){
self.redirect_url = (api.config.servers['web'].secure ? 'https' : 'http') + "://" + req.headers.host + '/api/' + self.action;
if(!this.redirect_url){
this.redirect_url = this.protocol + "://" + req.headers.host + '/api/' + this.action;
}

@@ -91,44 +88,2 @@

api.actions.actions[this.action][action.version] = action;
};
OAuth2Client.prototype.createUserAction = function(api){
var action = require('./actions/user');
action.name = this.user_action;
//oauth action to allow /api/oauth
api.actions.versions[this.user_action] = [action.version];
api.actions.actions[this.user_action] = {};
api.actions.actions[this.user_action][action.version] = action;
};
OAuth2Client.prototype.createLogoutAction = function(api){
var action = require('./actions/logout');
action.name = this.logout_action;
//oauth action to allow /api/oauth
api.actions.versions[this.logout_action] = [action.version];
api.actions.actions[this.logout_action] = {};
api.actions.actions[this.logout_action][action.version] = action;
};
OAuth2Client.prototype.createPreProcessor = function(api){
var self = this;
api.actions.preProcessors.push(function(connection, actionTemplate, next){
api.cache.load(self.action + ':connection:' + connection.id, function(err, value){
if(value){
connection.user = value.user;
connection.access_token = value.token;
}
next(connection, true);
});
});
};
{
"name": "actionhero-oauth2-client",
"version": "0.1.0",
"version": "1.0.0",
"description": "ActionHero OAuth2 Client",
"homepage": "",
"author": {
"name": "Philipp Waldmann"
"keywords": ["actionhero", "oauth2", "client"],
"author": "Philipp Waldmann <philipp.waldmann@s-team.at>",
"repository": {
"type": "git",
"url": "git://github.com/s-team/actionhero-oauth2-client.git"
},
"main": "./lib",
"dependencies": {
"simple-oauth2": ">= 0.1.x",
"request": ">= 2.31.x"
"simple-oauth2": ">= 0.1.x"
},
"devDependencies": {
}
"devDependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc