Skip to content

Commit 51d00a0

Browse files
refactor: Simplify the documentation
1 parent 17dd6b0 commit 51d00a0

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • docs/06-concepts/04-authentication/04-providers/02-email

docs/06-concepts/04-authentication/04-providers/02-email/01-setup.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ If a code cannot be sent, the failure is recorded in the session log and the sig
4848

4949
### Use your own email provider
5050

51-
Replace `ServerpodCloudEmailIdpConfig` with `EmailIdpConfigFromPasswords` to send the verification codes yourself. One convenient option is the [mailer](https://pub.dev/packages/mailer) package, which can send emails through any SMTP service. Most email providers, such as Resend, Sendgrid or Mandrill, support SMTP.
51+
Serverpod Cloud delivery is there to get sign-in working quickly, and it sends a standard message carrying your `appDisplayName`. You might prefer using a custom email provider to have full control over the body, layout, and language of the emails. For servers hosted outside of Serverpod Cloud, it is the only option.
5252

53-
Pass your own callbacks for the two codes:
53+
Changing the email provider is done by replacing `ServerpodCloudEmailIdpConfig` with `EmailIdpConfig`, which requires you to pass your own callbacks for the two codes. One convenient option is the [mailer](https://pub.dev/packages/mailer) package, which can send emails through any SMTP service. Most email providers, such as Resend, Sendgrid or Mandrill, support SMTP.
5454

5555
```dart
5656
import 'package:serverpod/serverpod.dart';
@@ -71,7 +71,9 @@ void run(List<String> args) async {
7171
identityProviderBuilders: [
7272
// Configure the Email Identity Provider
7373
// This is the basic configuration for the Email IDP to work.
74-
EmailIdpConfigFromPasswords(
74+
EmailIdpConfig(
75+
// Secret pepper to hash the password and verification code.
76+
secretHashPepper: pod.getPassword('emailSecretHashPepper')!,
7577
// Callback to send the registration verification code to the user.
7678
sendRegistrationVerificationCode: _sendRegistrationCode,
7779
// Callback to send the password reset verification code to the user.
@@ -108,14 +110,18 @@ void _sendPasswordResetCode(
108110
}
109111
```
110112

111-
The configuration takes these values:
113+
#### Basic configuration options
112114

113-
- `emailSecretHashPepper`: Required. A secret pepper used for hashing passwords and verification codes, read from the `emailSecretHashPepper` key in `config/passwords.yaml` or the `SERVERPOD_PASSWORD_emailSecretHashPepper` environment variable. Must be at least 10 characters long, but the [recommended pepper length](https://www.ietf.org/archive/id/draft-ietf-kitten-password-storage-04.html#name-storage-2) is 32 bytes.
115+
- `secretHashPepper`: Required. A secret pepper used for hashing passwords and verification codes. Must be at least 10 characters long, but the [recommended pepper length](https://www.ietf.org/archive/id/draft-ietf-kitten-password-storage-04.html#name-storage-2) is 32 bytes.
114116
- `sendRegistrationVerificationCode`: A callback that will be called to send the registration verification code to the user. Here you should call the email sending service to send the verification code to the user.
115117
- `sendPasswordResetVerificationCode`: A callback that will be called to send the password reset verification code to the user. Here you should call the email sending service to send the verification code to the user.
116118

117119
For more details on configuration options, such as customizing password requirements, verification code generation, rate limiting, and more, see the [configuration section](./configuration).
118120

121+
:::tip
122+
If you are using the `config/passwords.yaml` file or environment variables, you can use the `EmailIdpConfigFromPasswords` constructor to automatically load the secret pepper. It will expect the `emailSecretHashPepper` key or the `SERVERPOD_PASSWORD_emailSecretHashPepper` environment variable to be set with the secret pepper value.
123+
:::
124+
119125
## Client-side configuration
120126

121127
If you have configured the `SignInWidget` as described in the [setup section](../../setup#present-the-authentication-ui), the Email identity provider will be automatically detected and displayed in the sign-in widget.

0 commit comments

Comments
 (0)