简体   繁体   English

发送Email验证码不含asp.net核心标识

[英]Send Email verification code with out asp.net core identity

I know there is possible way to create&send email verification code using asp.net core identity.我知道有可能使用 asp.net 核心身份创建和发送 email 验证码。 But in my case I dont want to setup all tables which asp.net core identity uses.但就我而言,我不想设置 asp.net 核心标识使用的所有表。 I am thinking to create as a service to generate code by accepting email as input and provide api to verify.我正在考虑通过接受 email 作为输入并提供 api 来验证来创建生成代码的服务。

Is there any nuget package or custom way to create email verification code with out asp.net core identity?是否有任何 nuget package 或自定义方法来创建 email 身份验证码?

You can do this by yourself by creating one table to store the verification code and creat them using a random number generator.您可以自己创建一个表来存储验证码并使用随机数生成器创建它们。 then you can have some controller action get this random code and check in the table that it matches the email.那么您可以通过一些 controller 操作获取此随机代码并在表中检查它是否与 email 匹配。

The basic idea behind most verification codes is by combining;大多数验证码背后的基本思想是通过组合;

  • a hidden secret一个隐藏的秘密
  • some form of purpose for the token代币的某种形式的目的
  • a per-user value like the email address每个用户的值,例如 email 地址
  • a counter based on the current time.基于当前时间的计数器。

eg hash($"secret:email:{emailAddress}:{timestep}") .例如hash($"secret:email:{emailAddress}:{timestep}")

To verify, you would re-create the tokens for a small range of time values to see if any of them match.为了验证,您将为一小部分时间值重新创建令牌,以查看它们是否匹配。

The implementation used by asp netcore identity can be found on github . asp netcore identity 使用的实现可以在github上找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM