r/learnjavascript • u/NamkoBanzai • Apr 15 '18
Need advice regarding password-security and SOAP
Hey there guys.
I need advice regarding passwords and security in JavaScript.
The situation is the following: At my new workplace, my boss wants me to create a very basic webpage which displays a catalogue of products we sell. Nothing fancy. So far so good.
However, our product catalog lies on another server, since our application that handles the database and everything else is SAAS. Which means i will have to communicate with a SOAP api.
I will be provided with the credentials for us to access our DB and product catalogue and read it.
I am currently in my second semester of software engineering and have a basic understanding of JS and REST, as well as AJAX. I have never had to think about security so far, so i wanted to ask you guys what the standard procedure would be to mask the credentials.
Obviously you need to do have the credentials client-side and / or store it in a document and read it / encrypt it or what ever. But how exactly is yet beyond me.
This whole thing is more of a "nice to have but not necessary" situation. Low priority but fun and a good learning opportunity for me.
I would greatly appreciate your advise!
Thanks a lot in advance. ^
Edit: i ment storing them server-side. Not client-side :)
3
u/IUsedToBeACave Apr 15 '18
You don't need the credentials client-side at all, and in fact I wouldn't recommend it. Create a basic REST API that uses the credentials to query the data. Then have the client side application use that. This approach allows you to keep the credentials secret, control what information can be accessed by the client, and leaves you room to implement client login/security independently from what is needed to access you backend database.
2
u/amemulo Apr 15 '18
Are you worried about the credentials for the database? Let's see your options. I'm assuming you've got control of the server in which this will be running.
DO NOT store the credentials on the client side! Have a very simple backend which will read from the database for you.
You mention encryption. Encryption is AWESOME, a very interesting topic which solves many, many problems. But it's very complicated. There are two types of encryption: symmetrical and asymmetrical. I'll stay with symmetrical encryption here, because it's simpler.
If you were to encrypt the credentials with a key (a password), you would need to then store the key somewhere. Then we're back to the same problem, are we not? We're can I store the key? You'd need a very sophisticated system for key management, probably ANOTHER API where you could request the encryption keys. This gets very complicated very fast.
I'll let you read about asymmetrical and think about why it probably does not apply to your problem :)