|
4 | 4 | Accounts can be created in many different ways, such as through an anonymous session, email and password, OAuth authentication, magic URLs, and more.
|
5 | 5 | </p>
|
6 | 6 |
|
7 |
| -<h2><a href="/docs/authentication#account-vs-user-service" id="account-vs-user-service">Account vs User Service</a></h2> |
| 7 | +<h2><a href="/docs/authentication#account-vs-user-api" id="account-vs-user-api">Account vs Users API</a></h2> |
8 | 8 |
|
9 | 9 | <p>
|
10 | 10 | The Account API operates in the scope of the currently logged-in account and is usually used in a frontend or mobile app. The Users API is used in backend integrations and operates in an admin scope using an API key with access to all your project users.
|
@@ -92,6 +92,10 @@ promise.then(function (response) {
|
92 | 92 | OAuth is another way to authenticate a user using a multi-step process. When using OAuth to authenticate, the authentication request is initiated from the client application. The user is then redirected to an OAuth2 provider to complete the authentication step, and finally, the user is redirected back to the client application. This provides integration with many third-party services that provide their own OAuth integration as a more secure approach than providing a username/password directly.
|
93 | 93 | </p>
|
94 | 94 |
|
| 95 | +<p> |
| 96 | + In applications with first-party redirects, using OAuth2 for authentication is preferred. |
| 97 | +</p> |
| 98 | + |
95 | 99 | <p>
|
96 | 100 | The example below shows you how to authenticate with OAuth2 using the Web SDK and Amazon's OAuth system.
|
97 | 101 | </p>
|
@@ -251,34 +255,73 @@ promise.then(function (response) {
|
251 | 255 | Appwrite handles the persistence of the session in a consistent way across SDKs. After authenticating with an SDK, the SDK will persist the session so that the user will not need to log in again the next time they open the app. The mechanism for persistence depends on the SDK.
|
252 | 256 | </p>
|
253 | 257 |
|
254 |
| -<ul> |
255 |
| - <li class="margin-bottom-tiny">Web - Uses a session secure cookie and falls back to local storage when a session cookie is not available.</li> |
256 |
| - <li class="margin-bottom-tiny">Flutter - Uses a session cookie stored in Application Documents through the path_provider package.</li> |
257 |
| - <li class="margin-bottom-tiny">Apple - Uses a session cookie.</li> |
258 |
| - <li class="margin-bottom-tiny">Android - Uses a session cookie stored in SharedPreferences.</li> |
259 |
| -</ul> |
| 258 | +<div class="notice"> |
| 259 | + <h2>Best Practice</h2> |
| 260 | + <p>Only keep user sessions active as long as needed and only maintain <b>one</b> instance of the Client SDK in your app to avoid conflicting session data.</p> |
| 261 | +</div> |
| 262 | + |
| 263 | +<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large text-size-small vertical"> |
| 264 | + <thead> |
| 265 | + <tr> |
| 266 | + <th style="width: 80px"></th> |
| 267 | + <th style="width: 120px">SDK</th> |
| 268 | + <th>Persistence Method</th> |
| 269 | + </tr> |
| 270 | + </thead> |
| 271 | + <tbody> |
| 272 | + <tr> |
| 273 | + <td> |
| 274 | + <img src="/images-ee/platforms/web.svg" alt="Logo" height="30" class="force-light sdk-logo margin-start margin-end" /> |
| 275 | + <img src="/images-ee/platforms/dark/web.svg" alt="Logo" height="30" class="force-dark sdk-logo margin-start margin-end" /> |
| 276 | + </td> |
| 277 | + <td> |
| 278 | + Web |
| 279 | + </td> |
| 280 | + <td> |
| 281 | + Uses a session secure cookie and falls back to local storage when a session cookie is not available. |
| 282 | + </td> |
| 283 | + </tr> |
| 284 | + <tr> |
| 285 | + <td> |
| 286 | + <img src="/images-ee/platforms/flutter.svg" alt="Logo" height="30" class="force-light sdk-logo margin-start margin-end" /> |
| 287 | + <img src="/images-ee/platforms/dark/flutter.svg" alt="Logo" height="30" class="force-dark sdk-logo margin-start margin-end" /> |
| 288 | + </td> |
| 289 | + <td> |
| 290 | + Flutter |
| 291 | + </td> |
| 292 | + <td> |
| 293 | + Uses a session cookie stored in Application Documents through the <b>path_provider</b> package. |
| 294 | + </td> |
| 295 | + </tr> |
| 296 | + <tr> |
| 297 | + <td> |
| 298 | + <img src="/images-ee/platforms/apple.svg" alt="Logo" height="30" class="force-light sdk-logo margin-start margin-end" /> |
| 299 | + <img src="/images-ee/platforms/dark/apple.svg" alt="Logo" height="30" class="force-dark sdk-logo margin-start margin-end" /> |
| 300 | + </td> |
| 301 | + <td> |
| 302 | + Apple |
| 303 | + </td> |
| 304 | + <td> |
| 305 | + Uses a session cookie stored in <b>UserDefaults</b>. |
| 306 | + </td> |
| 307 | + </tr> |
| 308 | + <tr> |
| 309 | + <td> |
| 310 | + <img src="/images-ee/platforms/android.svg" alt="Logo" height="30" class="force-light sdk-logo margin-start margin-end" /> |
| 311 | + <img src="/images-ee/platforms/dark/android.svg" alt="Logo" height="30" class="force-dark sdk-logo margin-start margin-end" /> |
| 312 | + </td> |
| 313 | + <td> |
| 314 | + Android |
| 315 | + </td> |
| 316 | + <td> |
| 317 | + Uses a session cookie stored in <b>SharedPreferences</b>. |
| 318 | + </td> |
| 319 | + </tr> |
| 320 | + </tbody> |
| 321 | +</table> |
260 | 322 |
|
261 | 323 | <h2><a href="/docs/authentication#security" id="security">Security</a></h2>
|
262 | 324 |
|
263 | 325 | <p>
|
264 | 326 | Security is very important to protect users' data and privacy. Appwrite uses a <a href="/docs/permissions">permissions model</a> coupled with user sessions to ensure users only have access to certain information based on the permissions. With Appwrite services, including databases and storage, access is granted at the collection, bucket, document, or file level. This access is consistent across access to these items in relation to document access, file access, and real-time events.
|
265 | 327 | </p>
|
266 |
| - |
267 |
| -<h2><a href="/docs/authentication#best-practices" id="best-practices">Best Practices</a></h2> |
268 |
| - |
269 |
| -<p> |
270 |
| - Here are some common best practices when handling sessions and keys used for authentication purposes. |
271 |
| -</p> |
272 |
| - |
273 |
| -<ol> |
274 |
| - <li class="margin-bottom-tiny">Only keep user sessions active as long as needed.</li> |
275 |
| - <li class="margin-bottom-tiny">Only grant scopes required for your use case for your APIs keys, and nothing more.</li> |
276 |
| - <li class="margin-bottom-tiny">Access Appwrite via HTTPS to prevent any redirects from interfering with your requests.</li> |
277 |
| - <li class="margin-bottom-tiny">Prefer using OAuth2 for authentication with first-party redirects.</li> |
278 |
| - <li class="margin-bottom-tiny">Generate an SSL certification for the Appwrite instance.</li> |
279 |
| - <li class="margin-bottom-tiny">Keep API keys private and out of client-side code.</li> |
280 |
| - <li class="margin-bottom-tiny">Only maintain <b>1</b> instance of the Client SDK in your app to avoid conflicting session data.</li> |
281 |
| - <li class="margin-bottom-tiny">When using the realtime service to get users' documents, clean up and resubscribe to the correct resources to maintain the correct app state.</li> |
282 |
| - <li class="margin-bottom-tiny">Unsubscribing from old resources is also recommended to prevent possible race conditions.</li> |
283 |
| -</ol> |
284 |
| - |
|
0 commit comments