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
Copy file name to clipboardExpand all lines: docs_headless/src/content/docs/security/AuthProviderList.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,6 @@ layout: default
3
3
title: "Supported Auth Provider Backends"
4
4
---
5
5
6
-
# Supported Auth Provider Backends
7
-
8
6
It's very common that your auth logic is so specific that you'll need to write your own `authProvider`. However, the community has built a few open-source Auth Providers that may fit your need:
Copy file name to clipboardExpand all lines: docs_headless/src/content/docs/security/AuthProviderWriting.md
+4-7Lines changed: 4 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,7 @@
1
1
---
2
-
layout: default
3
2
title: "Writing An Auth Provider"
4
3
---
5
4
6
-
# Writing An Auth Provider
7
-
8
5
React-admin can use any authentication backend, but you have to write an adapter for it. This adapter is called an `authProvider`. The `authProvider` is a simple object with methods that react-admin calls to handle authentication and authorization.
9
6
10
7
## AuthProvider Interface Overview
@@ -29,7 +26,7 @@ const authProvider = {
29
26
**Tip**: If you're a TypeScript user, you can check that your `authProvider` is correct at compile-time using the `AuthProvider` type.
30
27
31
28
```tsx
32
-
importtype { AuthProvider } from'react-admin';
29
+
importtype { AuthProvider } from'ra-core';
33
30
34
31
const authProvider:AuthProvider= {
35
32
// ...
@@ -271,7 +268,7 @@ const authProvider = {
271
268
272
269
### `logout`
273
270
274
-
If you enable authentication, react-admin adds a logout button in the user menu in the top bar (or in the sliding menu on mobile). When the user clicks on the logout button, this calls the `authProvider.logout()` method, and removes potentially sensitive data stored in [the react-admin Store](./Store.md). Then the user gets redirected to the login page. The two previous sections also illustrated that react-admin can call `authProvider.logout()` itself, when the API returns a 403 error or when the local credentials expire.
271
+
If you enable authentication, react-admin adds a logout button in the user menu in the top bar (or in the sliding menu on mobile). When the user clicks on the logout button, this calls the `authProvider.logout()` method, and removes potentially sensitive data stored in [the react-admin Store](../guides/Store.md). Then the user gets redirected to the login page. The two previous sections also illustrated that react-admin can call `authProvider.logout()` itself, when the API returns a 403 error or when the local credentials expire.
275
272
276
273
<videocontrolsautoplayplaysinlinemutedloop>
277
274
<sourcesrc="../img/logout.mp4"type="video/mp4"/>
@@ -329,7 +326,7 @@ React-admin uses the `fullName` and the `avatar` (an image source, or a data-uri
329
326
**Tip**: You can use the `id` field to identify the current user in your code, by calling the `useGetIdentity` hook:
Copy file name to clipboardExpand all lines: docs_headless/src/content/docs/security/Authenticated.md
+4-7Lines changed: 4 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,24 @@
1
1
---
2
-
layout: default
3
-
title: "The Authenticated Component"
2
+
title: "<Authenticated>"
4
3
---
5
4
6
-
# `<Authenticated>`
7
-
8
5
The `<Authenticated>` component calls [`authProvider.checkAuth()`](./AuthProviderWriting.md#checkauth) on mount. If the current user is authenticated,`<Authenticated>` renders its child component. If the user is not authenticated, it redirects to the login page. While the authentication is being checked, `<Authenticated>` displays a loading component (empty by default).
9
6
10
7
## Usage
11
8
12
9
Use it as an alternative to the [`useAuthenticated()`](./useAuthenticated.md) hook when you can't use a hook, e.g. inside a `<Route element>` component:
0 commit comments