Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add sync method to get key #28

Open
wants to merge 2 commits into
base: v1.x/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions js/encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function encryptWithKey(text,key) {
return encrypted;
}

function getKeyFromPasswordSync(password,salt,length) {
var rounds = 500;
return crypto.pbkdf2Sync(password,salt,rounds,length,'sha256');
}

function getKeyFromPassword(password,salt,length,callback) {
var rounds = 500;
crypto.pbkdf2(password,salt,rounds,length,'sha256',(error, derivedKey) => {
Expand Down Expand Up @@ -54,6 +59,7 @@ function decryptWithKeyAndIV(text,key,iv) {
exports.encryptWithKeyAndIV = encryptWithKeyAndIV;
exports.decryptWithKeyAndIV = decryptWithKeyAndIV;
exports.getKeyFromPassword = getKeyFromPassword;
exports.getKeyFromPasswordSync = getKeyFromPasswordSync;
exports.encryptWithKey = encryptWithKey;
exports.decryptWithKey = decryptWithKey;

Expand Down
10 changes: 9 additions & 1 deletion js/plugin-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ Plugin.prototype = {
else {
throw new Error (`No file name for data service`)
}
// Make the relative path clear. process.cwd() is zlux-example-server/bin/
if (!path.isAbsolute(fileLocation)) {
Copy link
Contributor

@fkovinAtRocket fkovinAtRocket Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please provide some details as to why this is needed? What exactly did you do so that this makes a difference?

fileLocation = path.join(process.cwd(),fileLocation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this even be right? Will a data service ever be found under just process.cwd(), which is, as you're saying, 'zlux-example-server/bin/' ?

}
const nodeModule = require(fileLocation);
dataservice.nodeModule = nodeModule;
}
Expand Down Expand Up @@ -427,7 +431,11 @@ NodeAuthenticationPlugIn.prototype = {
},

init(context) {
const filepath = path.join(this.location, 'lib', this.filename);
let filepath = path.join(this.location, 'lib', this.filename);
// Make the relative path clear. process.cwd() is zlux-example-server/bin/
if (!path.isAbsolute(filepath)) {
filepath = path.join(process.cwd(),filepath);
}
bootstrapLogger.log(bootstrapLogger.INFO,
`Auth plugin ${this.identifier}: loading auth handler module ${filepath}`)
this.authenticationModule = require(filepath);
Expand Down