tags:

views:

223

answers:

2

I asked for PHP login system and I got answers,

  1. lots of files tactics
    * aaa.txt(content is aaa-pass)
    * bbb.txt(content is bbb-pass)
    * and scandir.
  2. XML
  3. CSV
  4. MySQL
  5. SQLite
  6. PEAR::AUTH

But no one mentioned about JSON.
but I feel JSON is the best way for me.
Because it looks easy , and PHP has JSON dedicated built-in function.
So I am considering to choose JSON for my login system,
but I want to confirm that there is any demerit
if I use JSON for my login script.

Anyone have any opinions?

A: 

I'd definitely give you a bunch of demerits, for two major reasons:

1) Never trust anything happening on the client, especially code executing on the client such a javascript. More simply, users can easily modify your authentication code, effectively rendering your authentication useless.

2) Your user database is directly http accessible and in plain text and most likely easily spotted from the source of your scripts or with a HTTP debugger. So after they end up as admin, they will have all your user names and passwords to play with as well.

If you need a login system, build a login system. Or at least fall back on whatever http authentication methods your web server supports.

Wyatt Barnett
To be fair, nobody mentioned the client (I'm **assuming** php can do JSON at the server); and most servers provide a mechanism to deny access to certain files,.
Marc Gravell
True, but if you deny access to your serliazed JSON password database, then your ajax scripts can't read it, defeating purpose of storing said password database.
Wyatt Barnett
I'm making the assumption that the OP is only talking about using JSON as the storage mechanism at the server (the same as a flat file, xml, etc), and that at no point would the client attempt to load it, AJAX or otherwise.
Marc Gravell
OP means me? .
Jonathan itou
@Jonathan itou - yes, you are the Original Poster
Dominic Rodger
+1  A: 

JSON is as good as any other plain text format for this. Just be sure not to store passwords in plain text. Save them only in a hashed form. And remember to use a salt when hashing. And, whenever it’s possible, try to keep this file out of document root, or at least deny access to it via server configuration.

Maciej Łebkowski