What are best practices for activation/registration/password-reset links in emails with nonce

前端 未结 3 902
刺人心
刺人心 2020-12-07 08:09

Applications send out emails to verify user accounts or reset a password. I believe the following is the way it should be and I am asking for references and implementations.

3条回答
  •  一个人的身影
    2020-12-07 08:27

    This question is very similar to Implementing secure, unique “single-use” activation URLs in ASP.NET (C#).

    My answer there is close to your scheme, with a few issues pointed out - such as short period of validity, handling double signups, etc.
    Your use of a cryptographic nonce is also important, that many tend to skip over - e.g. "lets just use a GUID"...

    One new point that you do raise, and this is important here, is wrt the idempotency of GET.
    Whilst I agree with your general intent, its clear that idempotency is in direct contradiction to one-time links, which is a necessity in some situations such as this.

    I would have liked to posit that this doesn't really violate the idempotentness of the GET, but unfortunately it does... On the other hand, the RFC says GET SHOULD be idempotent, its not a MUST. So I would say forgo it in this case, and stick to the one-time auto-invalidated links.

    If you really want to aim for strict RFC compliance, and not get into non-idempotent(?) GETs, you can have the GET page auto-submit the POST - kind of a loophole around that bit of the RFC, but legit, and you dont require the user to double-optin, and you're not bugging him...

    You dont really have to worry about preloading (are you talkng about CSRF, or browser-optimizers?)... CSRF is useless because of the nonce, and optimizers usually wont process javascript (used to auto-submit) on the preloaded page.

提交回复
热议问题