-
Notifications
You must be signed in to change notification settings - Fork 20
Sms Verification Scope Validation
Yugang Zhou edited this page Apr 24, 2019
·
1 revision
在应用中,可能存在多个功能需要短信验证保护。安全起见,希望验证码专码专用。如,尽管是同一个手机号,短信登录的验证码,和修改密码的验证码,应当独立分开使用。Daming提供了SVS机制,在请求短信验证码和验证短信验证码时,需要指定Scope,见API文档(TODO)
为避免User Agent传入非法的SVS,com.thebund1st.daming.core.SmsVerificationScopePattern为SVS的校验实现提供了抽象,你可以在项目中扩展该接口来定制校验机制。
Daming为SmsVerificationScopePattern提供了开箱即用的实现StaticSmsVerificationScopePattern,并可以通过配置文件/环境变量设置合法的SVS:
# application-{profile}.properties
# 可使用','分隔多个SVS
daming.sms.verification.scope.valid=SMS_LOGIN, VERY_IMPORTANT_OPERATION, ANOTHER
任何注册到Spring ApplicationContext的SmsVerificationScopePattern都可以替换Daming的默认实现:
@Component
public class MySmsVerificationScopePattern implements SmsVerificationScopePattern {
@Override
public boolean matches(SmsVerificationScope value) {...}
}
- 快速入门
- 文档
- 为什么要开发Daming
- 集成模式
- 安装Daming
- Sms Verification Scope
- 集成短信供应商
- 什么是Sms Verification JWT
- API
- 非生产环境支持
- 防止验证码暴力破解
- 验证码发送限流
- 设置验证码有效期
- 微服务模式的SDK (TBD)
- 已知问题
- 示例
- 变更历史(TBD)