-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Store property values encrypted #1260
Comments
One of many possible implementations: {
"name": "MyModel",
"properties": {
"name": { "type": "string", "encrypted": true }
}
} module.exports = function(MyModel) {
MyModel._encryptPropertyValue = function(propertyName, value, cb) {
// custom encryption algorithm
cb(null, encryptedPropertyValue);
};
MyModel._decryptPropertyValue = function(propertyName, encryptedValue, cb) {
// custom encryption algorithm
cb(null, value);
};
} |
As pointed out here #1226 (comment) I think we should aim for an Encrypt mixin. Suggestion:
The above will use Model.encryptAttribute(attr, data, options, cb); which will have a default implementation (once you run the mixin), which you can then override (in boot/ ... for example).
Use the given properties; when an encrypt function is given, define Model.encryptAttribute with it. |
has there been any more work on this ? |
@jmls loopbackio/loopback-datasource-juggler#599 added "loaded" hook and loopbackio/loopback-datasource-juggler#586 added "persist" hook. These two new hooks should allow you to implement encryption yourself. We don't have a higher-level support (like a mixin outlined above) yet. |
Let me add more context for anybody who may come across this closed issue: I personally agree with @fabien that encrypted properties can and thus should be implemented as a mixin. Additionally, I think it's best to keep this mixin outside of loopback core, to allow independent versioning and easier maintenance. If it turns out that the two hooks "loaded" and "persist" are not enough to support property encryption/decryption, then please open a new issue describing what is needed from LoopBack core to support this feature. |
We should provide an easy way how to encrypt property values on "save" and decrypt then on "load". At the moment, users have to implement operation hooks as a workaround.
Optionally, we can provide support for one-way encryption too, think of
User.password
.loopbackio/loopback-datasource-juggler#441
#1226
The text was updated successfully, but these errors were encountered: