MySQL PASSWORD() column: migration to MongoDB -
MySQL PASSWORD() column: migration to MongoDB -
i'm looking migrate table of user info shiny new mongodb rig. having problem wrapping head around how handle column of passwords. i'm using mysql's password() function store passwords. when thing constructed didn't see reason ever need reverse encryption, didn't see harm in using password() function. can't transfer passwords is, because (as far know) can't utilize password() same way in mongodb check validity of password.
any ideas?
you have several options:
option 1: lazy migration.keep both mysql , mongodb servers online , connected. when user attempts log in, check password against mongodb. if fails (ie, password never set), check against mysql. if succeeds, hash password , store in mongodb document.
downsides: mysql server has remain online forever (or @ to the lowest degree until users migrate).
upsides: can replace mysql password format own format (ie, bcrypt hashes or whatnot). don't have have knowledge of how mysql hashing passwords internally.
option 2: figure out how mysql password() function works, , replicate clientside.according simulating mysql's password() encryption using .net or ms sql algorithm mysql versions 4.1 , greater utilize password()
"*" + sha1(sha1("password"))
, more or less. if you're running older version, you'll need find out hashing algorithm is, , utilize instead. can take password, double sha1-hash it, prepend asterisk, , check see if value matches what's in db.
downsides: exact algorithm depends on version of mysql you're running, might have bit of digging depending on mysql version. you're still stuck using mysql password format in mongodb documents (though lazy upgrade, procedure similar described in alternative 1).
upsides: can migration 1 time , take mysql server offline.
mysql mongodb passwords
Comments
Post a Comment