Sending passwords over the web

后端 未结 4 630
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 04:02

So I\'m working on a mobile platform application that I\'d like to have users authenticate over the web. I was wondering the best way to do security. The user is sending a p

相关标签:
4条回答
  • 2021-01-03 04:31

    As Pekka pointed out, SSL is your best option.

    As an alternative, using SHA in JavaScript is pretty easy, fast, and it's already been written. Here's an example and here's a library: crypto.js

    0 讨论(0)
  • 2021-01-03 04:37

    You could use SSL if your client app supports it.

    0 讨论(0)
  • 2021-01-03 04:47

    For regular non-critical system most websites send the password in plain text over the Internet during a http post request. The password is then server side encoded by SHA1/MD5 and checked against the value in the database.

    You can also use https basic authentication, this will encode the password with a simple algorithm. But although it does not send the password in plain text, the encoding is so simple that it’s very (very!) easy to crack. But by using basic authentication, you cannot use a regular login form, you will need to do with the browsers support for basic authentication (not very user friendly!).

    If you need more security most websites just install a server side SSL certificate that you buy at an ISP (for example godaddy). This will make it possible to access you’re login script over an SSL encrypted connection. This solution is considered secure (as long as the password is not easy to guess or stolen).

    An other interesting, but uncommon approach, is to do the SHA1 encoding in JavaScript before doing a (Ajax) post request to the server (JS sha-1 example). In theory, this could deliver quite reasonable security…

    And if this all is still not enough you could consider installing client certificates or a response-challenge system with a calculator or SMS.

    0 讨论(0)
  • 2021-01-03 04:51
    1. If you want security, YOU. MUST. USE. HTTPS. With a proper, non-self-signed certificate. Whatever you do, identities that are authenticated in unencrypted communication will be trivial to steal. (Never mind the password, the attacker can simply steal the session cookie that is provided with every request.)
    2. Hashing is worthless in itself, you must salt it. (This is not really related to authentication - it is a second layer of defense for the case when someone steals your database. Which will probably happen sooner or later if you become a promising target.) Use bcrypt with long random per-user salt, sha* is insecure because it is too fast.
    3. Use methods that are already in use by large, security-aware projects. Those methods have, to some degree, withstood the test of time. There are challange-response based methods that avoid sending the password in any form, but crypto is hard, and it is very easy to implement secure algorithms in an insecure way. Use a good security framework (e.g. PHPass), don't rely on code that is not widely in use.
    0 讨论(0)
提交回复
热议问题