You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c6e8771
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/06-concepts/10-modules.md
+13-16Lines changed: 13 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,32 +2,30 @@
2
2
3
3
Serverpod is built around the concept of modules. A Serverpod module is similar to a Dart package but contains both server, client, and Flutter code. A module contains its own namespace for endpoints and methods to minimize the risk of conflicts.
4
4
5
-
Examples of modules are the `serverpod_auth` module and the `serverpod_chat` module, which both are maintained by the Serverpod team.
5
+
Examples of modules are the `serverpod_auth_core`and `serverpod_auth_idp` modules, which both are maintained by the Serverpod team.
6
6
7
7
## Adding a module to your project
8
8
9
9
### Server setup
10
10
11
11
To add a module to your project, you must include the server and client/Flutter packages in your project's `pubspec.yaml` files.
12
12
13
-
For example, to add the `serverpod_auth` module to your project, you need to add `serverpod_auth_server` to your server's `pubspec.yaml`:
13
+
For example, to add the `serverpod_auth_idp` module to your project, you need to add `serverpod_auth_idp_server` to your server's `pubspec.yaml`:
14
14
15
15
```yaml
16
16
dependencies:
17
-
serverpod_auth_server: ^1.x.x
17
+
serverpod_auth_idp_server: ^3.x.x
18
18
```
19
19
20
20
:::info
21
-
22
-
Make sure to replace `1.x.x` with the Serverpod version you are using. Serverpod uses the same version number for all official packages. If you use the same version, you will be sure that everything works together.
23
-
21
+
Make sure to replace `3.x.x` with the Serverpod version you are using. Serverpod uses the same version number for all official packages. If you use the same version, you will be sure that everything works together.
24
22
:::
25
23
26
-
In your `config/generator.yaml` you can optionally add the `serverpod_auth` module and give it a `nickname`. The nickname will determine how you reference the module from the client. If the module isn't added in the `generator.yaml`, the default nickname for the module will be used.
24
+
In your `config/generator.yaml` you can optionally add the `serverpod_auth_idp` module and give it a `nickname`. The nickname will determine how you reference the module from the client. If the module isn't added in the `generator.yaml`, the default nickname for the module will be used.
27
25
28
26
```yaml
29
27
modules:
30
-
serverpod_auth:
28
+
serverpod_auth_idp:
31
29
nickname: auth
32
30
```
33
31
@@ -51,7 +49,7 @@ In your client's `pubspec.yaml`, you will need to add the generated client code
51
49
52
50
```yaml
53
51
dependencies:
54
-
serverpod_auth_client: ^1.x.x
52
+
serverpod_auth_idp_client: ^3.x.x
55
53
```
56
54
57
55
### Flutter app setup
@@ -60,19 +58,20 @@ In your Flutter app, add the corresponding dart or Flutter package(s) to your `p
60
58
61
59
```yaml
62
60
dependencies:
63
-
serverpod_auth_shared_flutter: ^1.x.x
64
-
serverpod_auth_google_flutter: ^1.x.x
65
-
serverpod_auth_apple_flutter: ^1.x.x
61
+
serverpod_auth_idp_flutter: ^3.x.x
66
62
```
67
63
68
64
## Referencing a module
69
65
70
-
It can be useful to reference serializable objects in other modules from the YAML-files in your models. You do this by adding the module prefix, followed by the nickname of the package. For instance, this is how you reference a serializable class in the auth package.
66
+
It can be useful to reference serializable objects in other modules from the YAML-files in your models. You do this by adding the module prefix, followed by the nickname of the package. For instance, this is how you reference a serializable class in the `serverpod_auth_idp` package.
In your Flutter package, you most likely want to import the client libraries created by `serverpod create`.
93
92
94
93
:::info
95
-
96
94
Most modules will need a set of database tables to function. When naming the tables, you should use the module name as a prefix to the table name to avoid any conflicts. For instance, the Serverpod tables are prefixed with `serverpod_`.
Copy file name to clipboardExpand all lines: docs/06-concepts/11-authentication/01-setup.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Serverpod comes with built-in user management and authentication. It is possible
4
4
5
5
The list of identity providers is continuously growing and new providers are added as they are developed. If you want to contribute a new provider, please consider [contributing](/contribute) your code. See the [identity providers configuration](#identity-providers-configuration) section for details on all available providers.
6
6
7
-

7
+

For the full list of operations, see the [UserProfiles](https://pub.dev/documentation/serverpod_auth_core_server/latest/serverpod_auth_core_server/UserProfiles-class.html) class documentation.
42
42
43
+
### Setting a default user image
44
+
45
+
When logging in from some providers, the user image is automatically fetched and set as the user's profile picture - such as with Google Sign In. However, when an image is not found or the provider does not expose the picture, it is possible to set a default user image using the `UserProfileConfig` object.
46
+
47
+
```dart
48
+
pod.initializeAuthServices(
49
+
userProfileConfig: UserProfileConfig(
50
+
// NOTE: The `userImageGenerator` parameter is optional and defaults to
51
+
// the value below - which generates Gmail-style images. You can change
52
+
// this parameter to generate any kind of placeholder image. The function
53
+
// will be called when invoking the `setDefaultUserImage` method.
When referencing module classes in your model files, you can use a nickname for the module instead of the full module name. See the [modules documentation](../modules) for more information.
88
+
:::
89
+
90
+
62
91
The model above creates a relation to the `AuthUser` table and ensures that each user can only have one `MyDomainData` object. The `onDelete=Cascade` ensures that when the `AuthUser` is deleted, the `MyDomainData` object is also deleted.
63
92
64
93
This makes it easy to query the additional information later based on the user's `authId`.
Copy file name to clipboardExpand all lines: docs/06-concepts/11-authentication/04-providers/01-email/02-configuration.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,25 @@ final emailIdpConfig = EmailIdpConfigFromPasswords(
67
67
Remember to configure the `verificationCodeConfig` parameter on the `EmailSignInWidget` to match the length of the verification code you generate. Otherwise, users will never be able to enter the verification code correctly. See the [customizing the UI section](./customizing-the-ui) for more details.
68
68
:::
69
69
70
+
#### Bypassing verification code in development
71
+
72
+
To simplify testing, it is possible to bypass the verification code by using a custom verification code generator that always returns the same code. This can be configured only for the development run mode as below:
? () => 'aaaaaaaa' // Be sure to match the length used in production.
83
+
: defaultVerificationCodeGenerator,
84
+
),
85
+
],
86
+
);
87
+
```
88
+
70
89
### Reacting to events
71
90
72
91
Beyond the `sendRegistrationVerificationCode` and `sendPasswordResetVerificationCode` callbacks to send verification codes to the user, there are a few callbacks that can be used to react to events, such as `onAfterAccountCreated` and `onPasswordResetCompleted`. These can be useful for sending emails to the user to communicate the successful operation.
Copy file name to clipboardExpand all lines: docs/06-concepts/11-authentication/04-providers/02-google/02-configuration.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,3 +100,25 @@ final googleIdpConfig = GoogleIdpConfigFromPasswords(
100
100
},
101
101
);
102
102
```
103
+
104
+
### Lightweight Sign-In on the Flutter app
105
+
106
+
Lightweight sign-in is a feature that attempts to authenticate users previously logged in with Google automatically with minimal or no user interaction. When enabled, the Google authentication controller will try to sign in users seamlessly using platform-specific lightweight authentication methods. This feature is enabled by default, but can be disabled from the `GoogleSignInWidget` or `GoogleAuthController`.
If lightweight sign-in fails (e.g., no previous session exists or the user dismisses the prompt), the user can still use the regular sign-in button to authenticate manually.
120
+
:::
121
+
122
+
:::note
123
+
The lightweight sign-in attempt happens automatically when the controller is initialized, typically at app launch. If successful, users will be signed in without any additional interaction.
Copy file name to clipboardExpand all lines: docs/08-upgrading/01-upgrade-to-three.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -241,6 +241,30 @@ class MyEndpoint extends Endpoint {
241
241
242
242
Serverpod 3.0 includes several changes to the authentication system that improve type safety and performance.
243
243
244
+
### Custom authentication handlers
245
+
246
+
In the new authentication system, the default authentication header has changed from `Basic` to `Bearer` - which is now officially supported. This introduced a change for custom `AuthenticationHandler` implementations: the `token` parameter will now receive the token unwrapped from the `Bearer` prefix - just as it does for `Basic` tokens.
247
+
248
+
If your application relies on the default `authenticationHandler` function, no change is required. Only custom implementations that previously implemented `Bearer` authentication will need to be updated to expect the unwrapped token.
249
+
250
+
Another change when using custom authentication handlers is that tokens without scheme prefix are no longer supported by default to enforce HTTP header standards. The preferred fix is to wrap the token with the `Bearer` prefix, but this will invalidate existing tokens. If you are you are using a custom authentication handler in production and need to keep the old behavior, you can set the `validateHeaders` parameter to `false` in your `production.yaml` config file.
Copy file name to clipboardExpand all lines: versioned_docs/version-3.0.0/06-concepts/10-modules.md
+13-16Lines changed: 13 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,32 +2,30 @@
2
2
3
3
Serverpod is built around the concept of modules. A Serverpod module is similar to a Dart package but contains both server, client, and Flutter code. A module contains its own namespace for endpoints and methods to minimize the risk of conflicts.
4
4
5
-
Examples of modules are the `serverpod_auth` module and the `serverpod_chat` module, which both are maintained by the Serverpod team.
5
+
Examples of modules are the `serverpod_auth_core`and `serverpod_auth_idp` modules, which both are maintained by the Serverpod team.
6
6
7
7
## Adding a module to your project
8
8
9
9
### Server setup
10
10
11
11
To add a module to your project, you must include the server and client/Flutter packages in your project's `pubspec.yaml` files.
12
12
13
-
For example, to add the `serverpod_auth` module to your project, you need to add `serverpod_auth_server` to your server's `pubspec.yaml`:
13
+
For example, to add the `serverpod_auth_idp` module to your project, you need to add `serverpod_auth_idp_server` to your server's `pubspec.yaml`:
14
14
15
15
```yaml
16
16
dependencies:
17
-
serverpod_auth_server: ^1.x.x
17
+
serverpod_auth_idp_server: ^3.x.x
18
18
```
19
19
20
20
:::info
21
-
22
-
Make sure to replace `1.x.x` with the Serverpod version you are using. Serverpod uses the same version number for all official packages. If you use the same version, you will be sure that everything works together.
23
-
21
+
Make sure to replace `3.x.x` with the Serverpod version you are using. Serverpod uses the same version number for all official packages. If you use the same version, you will be sure that everything works together.
24
22
:::
25
23
26
-
In your `config/generator.yaml` you can optionally add the `serverpod_auth` module and give it a `nickname`. The nickname will determine how you reference the module from the client. If the module isn't added in the `generator.yaml`, the default nickname for the module will be used.
24
+
In your `config/generator.yaml` you can optionally add the `serverpod_auth_idp` module and give it a `nickname`. The nickname will determine how you reference the module from the client. If the module isn't added in the `generator.yaml`, the default nickname for the module will be used.
27
25
28
26
```yaml
29
27
modules:
30
-
serverpod_auth:
28
+
serverpod_auth_idp:
31
29
nickname: auth
32
30
```
33
31
@@ -51,7 +49,7 @@ In your client's `pubspec.yaml`, you will need to add the generated client code
51
49
52
50
```yaml
53
51
dependencies:
54
-
serverpod_auth_client: ^1.x.x
52
+
serverpod_auth_idp_client: ^3.x.x
55
53
```
56
54
57
55
### Flutter app setup
@@ -60,19 +58,20 @@ In your Flutter app, add the corresponding dart or Flutter package(s) to your `p
60
58
61
59
```yaml
62
60
dependencies:
63
-
serverpod_auth_shared_flutter: ^1.x.x
64
-
serverpod_auth_google_flutter: ^1.x.x
65
-
serverpod_auth_apple_flutter: ^1.x.x
61
+
serverpod_auth_idp_flutter: ^3.x.x
66
62
```
67
63
68
64
## Referencing a module
69
65
70
-
It can be useful to reference serializable objects in other modules from the YAML-files in your models. You do this by adding the module prefix, followed by the nickname of the package. For instance, this is how you reference a serializable class in the auth package.
66
+
It can be useful to reference serializable objects in other modules from the YAML-files in your models. You do this by adding the module prefix, followed by the nickname of the package. For instance, this is how you reference a serializable class in the `serverpod_auth_idp` package.
In your Flutter package, you most likely want to import the client libraries created by `serverpod create`.
93
92
94
93
:::info
95
-
96
94
Most modules will need a set of database tables to function. When naming the tables, you should use the module name as a prefix to the table name to avoid any conflicts. For instance, the Serverpod tables are prefixed with `serverpod_`.
Copy file name to clipboardExpand all lines: versioned_docs/version-3.0.0/06-concepts/11-authentication/01-setup.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Serverpod comes with built-in user management and authentication. It is possible
4
4
5
5
The list of identity providers is continuously growing and new providers are added as they are developed. If you want to contribute a new provider, please consider [contributing](/contribute) your code. See the [identity providers configuration](#identity-providers-configuration) section for details on all available providers.
6
6
7
-

7
+

Then, extend the abstract endpoint for refreshing JWT tokens to expose it on the server:
64
+
65
+
```dart
66
+
import 'package:serverpod_auth_idp_server/core.dart' as core;
67
+
68
+
class RefreshJwtTokensEndpoint extends core.RefreshJwtTokensEndpoint {}
69
+
```
70
+
63
71
### Token Manager Configuration
64
72
65
73
The authentication system uses token managers to handle authentication tokens. You need to configure at least one token manager to be used as the primary token manager. Additional token managers can be configured to be used for validation and management operations.
For the full list of operations, see the [UserProfiles](https://pub.dev/documentation/serverpod_auth_core_server/latest/serverpod_auth_core_server/UserProfiles-class.html) class documentation.
42
42
43
+
### Setting a default user image
44
+
45
+
When logging in from some providers, the user image is automatically fetched and set as the user's profile picture - such as with Google Sign In. However, when an image is not found or the provider does not expose the picture, it is possible to set a default user image using the `UserProfileConfig` object.
46
+
47
+
```dart
48
+
pod.initializeAuthServices(
49
+
userProfileConfig: UserProfileConfig(
50
+
// NOTE: The `userImageGenerator` parameter is optional and defaults to
51
+
// the value below - which generates Gmail-style images. You can change
52
+
// this parameter to generate any kind of placeholder image. The function
53
+
// will be called when invoking the `setDefaultUserImage` method.
When referencing module classes in your model files, you can use a nickname for the module instead of the full module name. See the [modules documentation](../modules) for more information.
88
+
:::
89
+
90
+
62
91
The model above creates a relation to the `AuthUser` table and ensures that each user can only have one `MyDomainData` object. The `onDelete=Cascade` ensures that when the `AuthUser` is deleted, the `MyDomainData` object is also deleted.
63
92
64
93
This makes it easy to query the additional information later based on the user's `authId`.
0 commit comments