Skip to content

Customize your sms pin scope validator

Yugang Zhou edited this page Aug 23, 2022 · 1 revision

What is Sms Verification Scope (a.k.a SVS)

You may have multiple scenario that needs SMS PIN, hence, for security reasons, you need to diff SMS PIN even for the same phone number, consider some one who submit SMS PIN for login for change password verification.

Daming provides a concept called SVS, the User Agent must provides 'SVS' when requesting for SMS PIN and verifying SMSP PIN

To protect daming from invalid User Agent,com.thebund1st.daming.core.SmsVerificationScopePattern provides an abstraction for validating SMS PIN scope.

By default implementation

By default, daming provides a by default implementation of 6 digits for SmsVerificationScopePattern, you can configure it by setting:

# application-{profile}.properties
# 可使用','分隔多个SVS
daming.sms.verification.scope.valid=SMS_LOGIN, VERY_IMPORTANT_OPERATION, ANOTHER

You can customize it by

Wiring any SmsVerificationScopePattern implementation into Spring ApplicationContext

@Component
public class MySmsVerificationScopePattern implements SmsVerificationScopePattern {

    @Override
    public boolean matches(SmsVerificationScope value) {...}
}
Clone this wiki locally