Skip to content

Commit 5351001

Browse files
authored
docs: Update path for old chat and auth examples (serverpod#346)
1 parent 774dd92 commit 5351001

15 files changed

Lines changed: 63 additions & 53 deletions

File tree

  • docs/06-concepts/11-authentication/04-providers
  • versioned_docs
    • version-1.0.0/04-concepts
    • version-1.1.0/04-concepts
    • version-1.1.1/05-concepts/09-authentication/04-providers
    • version-1.2.0/05-concepts/10-authentication/04-providers
    • version-2.0.0/05-concepts/10-authentication/04-providers
    • version-2.1.0/06-concepts/11-authentication/04-providers
    • version-2.2.0/06-concepts/11-authentication/04-providers
    • version-2.3.0/06-concepts/11-authentication/04-providers
    • version-2.4.0/06-concepts/11-authentication/04-providers
    • version-2.5.0/06-concepts/11-authentication/04-providers
    • version-2.6.0/06-concepts/11-authentication/04-providers
    • version-2.7.0/06-concepts/11-authentication/04-providers
    • version-2.8.0/06-concepts/11-authentication/04-providers
    • version-2.9.0/06-concepts/11-authentication/04-providers

‎docs/06-concepts/11-authentication/04-providers/01-email.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ await pod.start();
3434

3535
:::info
3636

37-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
37+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
3838

3939
:::
4040

‎versioned_docs/version-1.0.0/04-concepts/07-authentication.md‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Authentication
2+
23
Serverpod comes with built-in user management and authentication. You can either build your custom authentication method or use the `serverpod_auth` module. The module makes it easy to authenticate with email or social sign-ins.
34

45
## The basics
@@ -20,6 +21,7 @@ It's most common to use the `auth` module for handling sign ins, but you can als
2021
:::
2122

2223
### Restricting access to endpoints
24+
2325
It is common to want to restrict access to an endpoint to users that have signed in. You can do this by overriding the `requireLogin` property of the `Endpoint` class.
2426

2527
```dart
@@ -53,6 +55,7 @@ await Users.updateUserScopes(session, userId, {Scope.admin});
5355
```
5456

5557
## Installing the auth module
58+
5659
Serverpod's auth module makes it easy to authenticate users through email or 3rd parties. Currently supported is Signing in with email, Google, Apple, and Firebase. Future versions of the authentication module will include more options. Using this module requires some setup with Google and Apple to work.
5760

5861
The authentication module also handles basic user information, such as user names and profile pictures.
@@ -62,6 +65,7 @@ The authentication module also handles basic user information, such as user name
6265
Please refer to the previous section, [Modules](./modules), for instructions on how to add a module to your project.
6366

6467
## App setup
68+
6569
First, add dependencies to your app's `pubspec.yaml` file for the methods of signing in that you want to support. Make sure to use the same version numbers as for Serverpod itself.
6670

6771
```yaml
@@ -71,7 +75,7 @@ dependencies:
7175
serverpod_flutter: ^1.x.x
7276
auth_example_client:
7377
path: ../auth_example_client
74-
78+
7579
serverpod_auth_shared_flutter: ^1.x.x
7680
serverpod_auth_email_flutter: ^1.x.x
7781
serverpod_auth_google_flutter: ^1.x.x
@@ -107,11 +111,13 @@ void main() async {
107111
```
108112

109113
The `SessionManager` has useful methods for viewing and monitoring the user's current state:
114+
110115
- The `signedInUser` will return a `UserInfo` if the user is currently signed in (or `null` if the user isn't signed in).
111116
- Use the `addListener` method to get notified of changes to the user's signed in state.
112117
- Sign out a user by calling the `signOut` method.
113118

114119
## Setting up Sign in with Email
120+
115121
To properly configure Sign in with Email, you must connect your Serverpod to an external service that can send the emails. 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 Sendgrid or Mandrill, support SMTP.
116122

117123
In your main `server.dart` file, you can configure the auth module. First, make sure to include the module:
@@ -135,18 +141,21 @@ auth.AuthConfig.set(auth.AuthConfig(
135141
// Start the server.
136142
await pod.start();
137143
```
144+
138145
:::info
139146

140-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
147+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
141148

142149
:::
143150

144151
In your app, you will need to add the `serverpod_auth_email_flutter` package to your `pubspec.yaml`. The package includes both methods for creating a custom email sign-in form and a pre-made `SignInWithEmailButton` widget. If you are building custom forms, it is helpful to read the documentation provided in the module and review the code in the [SignInWithEmailDialog](https://github.com/serverpod/serverpod/blob/main/modules/serverpod_auth/serverpod_auth_email_flutter/lib/src/signin_dialog.dart).
145152

146153
## Setting up Sign in with Google
154+
147155
To set up Sign in with Google, you will need a Google account for your organization and set up a new project. For the project, you need to set up _Credentials_ and _Oauth consent screen_. You will also need to add the `serverpod_auth_google_flutter` package to your app and do some additional setup depending on each platform.
148156

149157
### Configure Google Cloud console and your server
158+
150159
In the Google Cloud console, you need to set up a few things:
151160

152161
1. Activate the _People API_ for your project. You find it in _APIs & Services_ > _Enabled APIs & services_.
@@ -155,7 +164,7 @@ In the Google Cloud console, you need to set up a few things:
155164
- Add `.../auth/userinfo.email` and `.../auth/userinfo.profile` to your `Scopes`.
156165
3. Add OAuth 2.0 credentials for your web application. Do this under _APIs & Services_ > _Credentials_.
157166
- Create a _Web application OAuth Client ID_. This is required even if you only want to provide sign-in with iOS or Android, as the server uses it to access Google's APIs.
158-
- For _Authorized JavaScript origins`, enter your domain name.
167+
- For \_Authorized JavaScript origins`, enter your domain name.
159168
- For _Authorized redirect URIs_, enter your domain name. You may also want to add your development server here, e.g., `http://localhost:8080`.
160169
- Download the JSON file for your web application OAuth client. This file contains both the client id and the client secret. Rename the file to `google_client_secret.json` and place it in your server's `config` directory.
161170
4. Add OAuth 2.0 credentials for iOS and Android.
@@ -172,6 +181,7 @@ The `google_client_secret.json` contains a private key and should not be version
172181
:::
173182

174183
### Configure your app
184+
175185
You need to take platform-dependent steps to configure Sign in with Google in your app.
176186

177187
- Add the `serverpod_auth_google_flutter` package to your app.
@@ -185,6 +195,7 @@ Rather than using the `GoogleService-Info.plist` file for iOS, you can pass the
185195
:::
186196

187197
### Calling Google APIs
198+
188199
The default setup allows access to basic user information, such as email, profile image, and name. You may require additional access scopes, such as accessing a user's calendar, contacts, or files. To do this, you will need to:
189200

190201
- Add the required scopes to the OAuth consent screen.
@@ -227,11 +238,13 @@ Adding additional scopes may require approval by Google. On the OAuth consent sc
227238
:::
228239

229240
## Setting up Sign in with Apple
241+
230242
You will need an Apple developer account to configure Sign in with Apple. Follow the instructions in [sign_in_with_apple](https://pub.dev/packages/sign_in_with_apple).
231243

232244
_Note that Sign in with Apple may not work on some versions of the Simulator (iOS 13.5 works). This issue doesn't affect real devices._
233245

234246
## Setting up Sign in with Firebase
247+
235248
Serverpod uses FlutterFire UI to handle authentication through Firebase. It allows you to add social sign-in types that Serverpod doesn't directly support.
236249

237250
To add authentication with Firebase, you must first install and initialize the Firebase CLI tools and Flutter fire. Follow the instructions [here](https://firebase.google.com/docs/flutter/setup?platform=web) for your Flutter project. In the Firebase console, configure the different social sign-ins you plan to use. Then pass your provider configurations to either the signInWithFirebase method or the SignInWithFirebaseButton of the [serverpod_auth_firebase_flutter](https://pub.dev/packages/serverpod_auth_firebase_flutter) package.
@@ -245,6 +258,7 @@ Serverpod automatically merges accounts that are using the same email addresses,
245258
:::
246259

247260
## Working with users
261+
248262
It's a common task to read or update user information on your server. You can always retrieve the id of a signed-in user through the session object.
249263

250264
```dart
@@ -266,6 +280,7 @@ The `Users` class contains many other convenient methods for working with users.
266280
:::
267281

268282
## Displaying or editing user images
283+
269284
The module has built-in methods for handling a user's basic settings, including uploading new profile pictures.
270285

271286
![UserImageButton](https://github.com/serverpod/serverpod/raw/main/misc/images/user-image-button.png)

‎versioned_docs/version-1.1.0/04-concepts/09-authentication.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ await pod.start();
140140
```
141141
:::info
142142

143-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
143+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
144144

145145
:::
146146

‎versioned_docs/version-1.1.1/05-concepts/09-authentication/04-providers/01-email.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ A comprehensive tutorial covering email/password sign-in complete with sending t
88
You need to install the auth module before you continue, see [Setup](../setup).
99
:::
1010

11-
1211
## Server-side Configuration
1312

14-
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
13+
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
1514

1615
```dart
1716
import 'package:serverpod_auth_server/module.dart' as auth;
@@ -35,7 +34,7 @@ await pod.start();
3534

3635
:::info
3736

38-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
37+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
3938

4039
:::
4140

@@ -79,7 +78,6 @@ The triggered modal will look like this:
7978

8079
![SignInWithEmailDialog](/img/authentication/providers/email/2-auth-email-dialog.png)
8180

82-
8381
## Custom UI with EmailAuthController
8482

8583
The `serverpod_auth_email_flutter` module provides the `EmailAuthController` class, which encapsulates the functionality for email/password authentication. You can use this class and create a custom UI for user registration, login, and password management.

‎versioned_docs/version-1.2.0/05-concepts/10-authentication/04-providers/01-email.md‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ A comprehensive tutorial covering email/password sign-in complete with sending t
88
You need to install the auth module before you continue, see [Setup](../setup).
99
:::
1010

11-
1211
## Server-side Configuration
1312

14-
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
13+
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
1514

1615
```dart
1716
import 'package:serverpod_auth_server/module.dart' as auth;
@@ -35,7 +34,7 @@ await pod.start();
3534

3635
:::info
3736

38-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
37+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
3938

4039
:::
4140

@@ -79,7 +78,6 @@ The triggered modal will look like this:
7978

8079
![SignInWithEmailDialog](/img/authentication/providers/email/2-auth-email-dialog.png)
8180

82-
8381
## Custom UI with EmailAuthController
8482

8583
The `serverpod_auth_email_flutter` module provides the `EmailAuthController` class, which encapsulates the functionality for email/password authentication. You can use this class and create a custom UI for user registration, login, and password management.
@@ -122,7 +120,6 @@ await authController.resetPassword(email, verificationCode, password);
122120

123121
After the password has been reset you have to call the `signIn` method to log in. This can be achieved by either letting the user type in the details again or simply chaining the `resetPassword` method and the `singIn` method for a seamless UX.
124122

125-
126123
## Password storage security
127124

128125
Serverpod provides some additional configurable options to provide extra layers of security for stored password hashes.
@@ -144,13 +141,13 @@ development:
144141
emailPasswordPepper: 'your-pepper'
145142
```
146143

147-
It is essential to keep the pepper secret and never expose it to the client.
144+
It is essential to keep the pepper secret and never expose it to the client.
148145

149-
If the pepper is changed, all passwords in the database will need to be re-hashed with the new pepper.
146+
If the pepper is changed, all passwords in the database will need to be re-hashed with the new pepper.
150147

151148
### Secure random
152149

153-
Serverpod uses the `dart:math` library to generate random salts for password hashing. By default, if no secure random number generator is available, a cryptographically unsecure random number is used.
150+
Serverpod uses the `dart:math` library to generate random salts for password hashing. By default, if no secure random number generator is available, a cryptographically unsecure random number is used.
154151

155152
It is possible to prevent this fallback by setting the `allowUnsecureRandom` property in the `AuthConfig` to `false`. If the `allowUnsecureRandom` property is false, the server will throw an exception if a secure random number generator is unavailable.
156153

‎versioned_docs/version-2.0.0/05-concepts/10-authentication/04-providers/01-email.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You need to install the auth module before you continue, see [Setup](../setup).
1010

1111
## Server-side Configuration
1212

13-
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
13+
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
1414

1515
```dart
1616
import 'package:serverpod_auth_server/module.dart' as auth;
@@ -34,7 +34,7 @@ await pod.start();
3434

3535
:::info
3636

37-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
37+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
3838

3939
:::
4040

@@ -141,7 +141,7 @@ development:
141141
emailPasswordPepper: 'your-pepper'
142142
```
143143

144-
It is essential to keep the pepper secret and never expose it to the client.
144+
It is essential to keep the pepper secret and never expose it to the client.
145145

146146
:::warning
147147

‎versioned_docs/version-2.1.0/06-concepts/11-authentication/04-providers/01-email.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You need to install the auth module before you continue, see [Setup](../setup).
1010

1111
## Server-side configuration
1212

13-
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
13+
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
1414

1515
```dart
1616
import 'package:serverpod_auth_server/module.dart' as auth;
@@ -34,7 +34,7 @@ await pod.start();
3434

3535
:::info
3636

37-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
37+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
3838

3939
:::
4040

@@ -141,7 +141,7 @@ development:
141141
emailPasswordPepper: 'your-pepper'
142142
```
143143

144-
It is essential to keep the pepper secret and never expose it to the client.
144+
It is essential to keep the pepper secret and never expose it to the client.
145145

146146
:::warning
147147

@@ -190,4 +190,4 @@ It could be useful if you already have stored passwords that should be preserved
190190

191191
Using a custom hash generator will permanently disrupt compatibility with the default hash generator.
192192

193-
:::
193+
:::

‎versioned_docs/version-2.2.0/06-concepts/11-authentication/04-providers/01-email.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You need to install the auth module before you continue, see [Setup](../setup).
1010

1111
## Server-side configuration
1212

13-
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
13+
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
1414

1515
```dart
1616
import 'package:serverpod_auth_server/module.dart' as auth;
@@ -34,7 +34,7 @@ await pod.start();
3434

3535
:::info
3636

37-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
37+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
3838

3939
:::
4040

@@ -141,7 +141,7 @@ development:
141141
emailPasswordPepper: 'your-pepper'
142142
```
143143

144-
It is essential to keep the pepper secret and never expose it to the client.
144+
It is essential to keep the pepper secret and never expose it to the client.
145145

146146
:::warning
147147

@@ -190,4 +190,4 @@ It could be useful if you already have stored passwords that should be preserved
190190

191191
Using a custom hash generator will permanently disrupt compatibility with the default hash generator.
192192

193-
:::
193+
:::

‎versioned_docs/version-2.3.0/06-concepts/11-authentication/04-providers/01-email.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You need to install the auth module before you continue, see [Setup](../setup).
1010

1111
## Server-side configuration
1212

13-
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
13+
In your main `server.dart` file, import the `serverpod_auth_server` module, and set up the authentication configuration:
1414

1515
```dart
1616
import 'package:serverpod_auth_server/module.dart' as auth;
@@ -34,7 +34,7 @@ await pod.start();
3434

3535
:::info
3636

37-
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/chat/chat_server/lib/server.dart).
37+
For debugging purposes, you can print the validation code to the console. The chat module example does just this. You can view that code [here](https://github.com/serverpod/serverpod/blob/main/examples/legacy/chat/chat_server/lib/server.dart).
3838

3939
:::
4040

@@ -141,7 +141,7 @@ development:
141141
emailPasswordPepper: 'your-pepper'
142142
```
143143

144-
It is essential to keep the pepper secret and never expose it to the client.
144+
It is essential to keep the pepper secret and never expose it to the client.
145145

146146
:::warning
147147

@@ -190,4 +190,4 @@ It could be useful if you already have stored passwords that should be preserved
190190

191191
Using a custom hash generator will permanently disrupt compatibility with the default hash generator.
192192

193-
:::
193+
:::

0 commit comments

Comments
 (0)