How to Implement Password Resets?

前端 未结 7 1848
离开以前
离开以前 2020-12-07 07:05

I\'m working on an application in ASP.NET, and was wondering specifically how I could implement a Password Reset function if I wanted to roll my own.

S

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 07:49

    Lots of good answers here, I wont bother repeating it all...

    Except for one issue, which is repeated by almost every answer here, even though its wrong:

    Guids are (realistically) unique and statistically impossible to guess.

    This is not true, GUIDs are very weak identifiers, and should NOT be used to allow access to a user's account.
    If you examine the structure, you get a total of 128 bits at most... which is not considered a lot nowadays.
    Out of which the first half is typical invariant (for the generating system), and half of whats left is time-dependant (or something else similar).
    All in all, its a very weak and easily bruteforced mechanism.

    So don't use that!

    Instead, simply use a cryptographically strong random number generator (System.Security.Cryptography.RNGCryptoServiceProvider), and get at least 256 bits of raw entropy.

    All the rest, as the numerous other answers provided.

提交回复
热议问题