You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.8 KiB
2.8 KiB
LINGYUN.Abp.OpenIddict.Sms
Introduction
LINGYUN.Abp.OpenIddict.Sms is an SMS verification extension module for OpenIddict, providing authentication functionality based on phone numbers and SMS verification codes.
Features
-
SMS Verification Code Authentication
- Support for phone number login
- Support for SMS verification code validation
- Support for multi-tenant authentication
-
User Management Integration
- Support for finding users by phone number
- Support for account lockout policy
- Support for failed attempt counting
-
Security Logging
- Record login attempts
- Record verification code failures
- Record account lockouts
-
Localization Support
- Integrated with ABP localization framework
- Support for custom error messages
Installation
dotnet add package LINGYUN.Abp.OpenIddict.Sms
Usage
-
Add
[DependsOn(typeof(AbpOpenIddictSmsModule))]to your module class. -
Configure OpenIddict server:
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictServerBuilder>(builder =>
{
// Allow SMS verification code authentication flow
builder.AllowSmsFlow();
});
}
- Usage example:
POST /connect/token
Content-Type: application/x-www-form-urlencoded
grant_type=sms&
phone_number=13800138000&
phone_verify=123456&
scope=openid profile
Parameters
-
phone_number (required)
- Phone number
- Must be a valid phone number format
-
phone_verify (required)
- SMS verification code
- Must be a valid verification code
-
scope (optional)
- Requested permission scopes
- Defaults include openid profile
Error Codes
- invalid_grant
- GrantTypeInvalid - Authorization type not allowed
- PhoneVerifyInvalid - Phone verification code invalid or expired
- PhoneOrTokenCodeNotFound - Phone number or verification code not provided
- PhoneNumberNotRegister - Phone number not registered
Notes
- Phone number must be registered
- Verification codes have limited validity
- Failed verifications increase failure count
- Multiple verification failures may lead to account lockout
- All authentication operations are recorded in security logs
- HTTPS is recommended in production environments