feat(sms): add selectable provider strategy
This commit is contained in:
20
README.md
20
README.md
@@ -1,11 +1,11 @@
|
||||
# Gapido Backend Code Challenge
|
||||
|
||||
Python gRPC OTP authentication service with MongoDB, Redis, RabbitMQ, and a Kavenegar SMS adapter.
|
||||
Python gRPC OTP authentication service with MongoDB, Redis, RabbitMQ, and selectable SMS providers.
|
||||
|
||||
## Architecture
|
||||
|
||||
- `auth-service`: async `grpc.aio` API for OTP login, token refresh, token revocation, and RBAC demo methods.
|
||||
- `sms-worker`: RabbitMQ consumer that sends OTP messages through Kavenegar.
|
||||
- `sms-worker`: RabbitMQ consumer that sends OTP messages through the configured SMS provider.
|
||||
- MongoDB stores users and refresh-token sessions.
|
||||
- Redis stores OTP hashes, TTL, verification attempts, and OTP request rate limits.
|
||||
- RabbitMQ decouples authentication from SMS delivery.
|
||||
@@ -19,6 +19,19 @@ docker compose up --build
|
||||
|
||||
The gRPC service listens on `localhost:50051`. RabbitMQ management is available at `http://localhost:15672` with `guest` / `guest`.
|
||||
|
||||
## SMS Provider
|
||||
|
||||
The SMS integration uses the Strategy pattern behind the `SmsClient` port. Select the provider with:
|
||||
|
||||
```env
|
||||
SMS_PROVIDER=kavenegar
|
||||
```
|
||||
|
||||
Supported values:
|
||||
|
||||
- `kavenegar`: uses `KAVENEGAR_API_KEY` and `KAVENEGAR_LOGIN_TEMPLATE`.
|
||||
- `sms_ir`: uses `SMS_IR_API_KEY` and `SMS_IR_VERIFY_TEMPLATE_ID`.
|
||||
|
||||
## Local Development
|
||||
|
||||
```bash
|
||||
@@ -50,5 +63,4 @@ authorization: Bearer <access_token>
|
||||
- OTP requests are rate-limited per mobile number and client identity.
|
||||
- Refresh tokens are opaque random values; only SHA-256 hashes are persisted.
|
||||
- Refresh tokens rotate on use.
|
||||
- Kavenegar is hidden behind an adapter and mocked in tests.
|
||||
|
||||
- SMS providers are hidden behind adapters and mocked in tests.
|
||||
|
||||
Reference in New Issue
Block a user