Socket
Socket
Sign inDemoInstall

@cgignite/ignite-auth

Package Overview
Dependencies
26
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.0.7

lib/basic-config.html

89

lib/oauth2-client.js
module.exports = function(RED)
{
const request = require('request');
const ClientOAuth2 = require('client-oauth2')
const { ClientCredentials, ResourceOwnerPassword, AuthorizationCode } = require('simple-oauth2');

@@ -15,11 +14,14 @@ function oauth2Client(config)

this.on('input', function (msg) {
var authClient= new ClientOAuth2({
clientId: node.auth2Config.clientId,
clientSecret: node.auth2Config.credentials.clientSecret,
accessTokenUri: node.auth2Config.accessTokenUrl,
authorizationUri: node.auth2Config.authUrl,
redirectUri: node.auth2Config.redirectUrl,
scopes: node.auth2Config.scope.split(',')
});
var authConfig = {
client: {
id: node.auth2Config.clientId,
secret: node.auth2Config.credentials.clientSecret
},
auth: {
//tokenHost: node.auth2Config.accessTokenUrl,
tokenPath : ' ',
//authorizeHost : node.auth2Config.authUrl,
authorizePath: ' '
}
};
var payloadAttribute = "payload";

@@ -30,20 +32,39 @@ if(node.outputlocation && node.outputlocation.length > 0)

}
var output;
switch(node.flow)
{
case "loginurl":
msg[payloadAttribute] = authClient.code.getUri();
node.send(msg);
authConfig.auth.authorizeHost = node.auth2Config.authUrl;
authConfig.auth.tokenHost = node.auth2Config.accessTokenUrl;
var client = new AuthorizationCode(authConfig);
var authorizationUri = client.authorizeURL({
redirect_uri: node.auth2Config.redirectUrl,
scope: node.auth2Config.scope,
state: ''
});
msg.statusCode = 303;
msg.headers = {
Location: authorizationUri
};
node.send(msg);
break;
case "gettoken":
authClient.code.getToken(msg.req.originalUrl).then(
function(r){
msg[payloadAttribute] = r.data;
node.send(msg);
}
).catch(
function(e){
msg[payloadAttribute] = e.body;
node.send(msg);
});
break;
authConfig.auth.authorizeHost = node.auth2Config.authUrl;
authConfig.auth.tokenHost = node.auth2Config.accessTokenUrl;
var client = new AuthorizationCode(authConfig);
var tokenParams = {
code: msg.req.query.code,
redirect_uri: node.auth2Config.redirectUrl,
scope: node.auth2Config.scope,
};
client.getToken(tokenParams).then(function(r)
{
output = r;
}).catch(function(e){
output = e.data.payload;
}).finally(function(){
msg[payloadAttribute] = output;
node.send(msg);
});
break;
case "usercredential":

@@ -60,9 +81,17 @@ var username = node.auth2Config.username;

}
authClient.owner.getToken(username, password).then(function(r)
authConfig.auth.tokenHost = node.auth2Config.accessTokenUrl;
var client = new ResourceOwnerPassword(authConfig);
var tokenParams = {
username: username,
password: password,
scope: node.auth2Config.scope,
};
client.getToken(tokenParams).then(function(r)
{
msg[payloadAttribute] = r.data;
node.send(msg);
output = r;
}).catch(function(e){
msg[payloadAttribute] = e.body;
node.send(msg);
output = e.data.payload;
}).finally(function(){
msg[payloadAttribute] = output;
node.send(msg);
});

@@ -79,3 +108,3 @@ break;

}
RED.nodes.registerType('oauth2 client', oauth2Client);
RED.nodes.registerType('oauth2', oauth2Client);
};

@@ -5,4 +5,7 @@ {

"nodes": {
"auth": "lib/auth.js",
"auth-config": "lib/auth-config.js",
"decode":"lib/decode.js",
"jwt": "lib/jwt.js",
"jwt-config": "lib/jwt-config.js",
"basic": "lib/basic.js",
"basic-config": "lib/basic-config.js",
"oauth2-client": "lib/oauth2-client.js",

@@ -12,3 +15,3 @@ "oauth2-client-config": "lib/oauth2-client-config.js"

},
"version": "1.0.5",
"version": "1.0.7",
"description": "Auth node allows you to integrate security withing your Ignite APIs and apps",

@@ -31,7 +34,6 @@ "scripts": {},

"dependencies": {
"client-oauth2": "^4.3.3",
"jsonwebtoken": "^8.5.1",
"request": "^2.88.2"
"simple-oauth2": "^4.1.0"
},
"devDependencies": {}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc