Reputation: 93
I'm trying to achieve the following through Worklight.
What I want to do is to unify these two approaches so that the user needn't enter two sets of credentials to access these two different sets of features. One possible solution that came to my mind is just to encrypt the JSONStore and perform the adapter authentication without the intervention of the user. But I don't think that it's secure.
Any advice or approach to solve this issue?
Upvotes: 2
Views: 575
Reputation: 5111
The following is just an idea, I'm not a security expert.
Requirements:
Steps:
var myHash = md5(loginField.getUser() + loginField.getPassword())
. You can find md5 JavaScript libraries on Github. WL.JSONStore.init(..., {password: myHash})
. loginField = null; myHash = null
). Alternatively, you could just generate the hash on the server and store it, without having the client send it back, just make sure both client and server are using the same hashing algorithm.WL.JSONStore.changePassword(oldHash, newHash)
.Optional: You may want to consider using a salt. For example: var salt = Math.random(), myHash = md5(loginField.getUser() + loginField.getPassword() + salt)
.
You will need to store the salt somewhere so you can re-generate the hash once the user returns to the application. You should be able to init another unencrypted store to persist it. For example WL.JSONStore.init(..., {username: 'metadata'}).then(function(){/*add salt to store*/})
. More information regarding using two stores here.
Upvotes: 2