Providers
Providers are pluggable components in Comby that handle external communication and integrations. They allow you to decouple the application logic from specific delivery mechanisms, making it easy to switch between different services without changing your core business logic.
Comby currently supports two types of providers:
- MFA Providers - Multi-factor authentication delivery mechanisms
- Email Providers - Email delivery services
Why Use Providers?
Providers offer several benefits:
- Decoupling: Separate business logic from delivery mechanisms
- Flexibility: Easily switch between different service providers
- Testing: Use NoOp providers during development and testing
- Customization: Implement custom providers for specific requirements
- Templates: Override default message templates per action
Common Features
All providers share common design patterns:
Interface-Based Design
Each provider type implements a specific interface, ensuring consistent behavior across different implementations.
Template Support
Providers support customizable templates with placeholder replacement:
provider.WithTemplate(
"auth-account-login-opaque",
"Login Code for {appName}",
"Your verification code is: {code}\n\nValid for {expiresIn} minutes.",
)Placeholders use the format {key} and are replaced with values from metadata.
Method Chaining
Most configuration methods return the provider instance, allowing for clean method chaining:
provider := NewSendgridEmailProvider(apiKey, sender, name).
WithTemplate("action1", "Subject 1", "Body 1").
WithTemplate("action2", "Subject 2", "Body 2")Provider Types
Each provider category defines supported types:
| MFA Provider Types | Email Provider Types |
|---|---|
email | smtp |
sms | sendgrid |
totp | ses |
webauthn | mailgun |
push | custom |
custom | noop |
noop |
NoOp Providers
Each provider type includes a noop (no-operation) variant for development and testing. NoOp providers implement the interface but don't perform actual operations, making them ideal for:
- Local development without external service dependencies
- Testing without sending real messages
- CI/CD pipelines where external communication is disabled
Next Steps
- Learn about MFA Providers for multi-factor authentication
- Explore Email Providers for email delivery