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: CONTRIBUTING.md
+20-16Lines changed: 20 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,8 @@
2
2
3
3
First of all, thank you for contributing, you're awesome!
4
4
5
-
To have your code integrated in the API Platform documentation project, there are some rules to follow, but don't panic, it's easy!
5
+
To have your code integrated in the API Platform documentation project, there are some rules to
6
+
follow, but don't panic, it's easy!
6
7
7
8
## Reporting Bugs in the documentation
8
9
@@ -12,33 +13,36 @@ Before submitting your issue:
12
13
- A clear title to resume the issue
13
14
- A description of the workflow needed to reproduce the bug
14
15
15
-
> [!NOTE]
16
-
> Don't hesitate giving as much information as you can.
16
+
> [!NOTE] Don't hesitate giving as much information as you can.
17
17
18
18
## Code of Conduct
19
19
20
-
By contributing to this project, you agree to abide by our [Code of Conduct](https://github.com/api-platform/docs#coc-ov-file). We expect all contributors to foster a welcoming and inclusive environment.
20
+
By contributing to this project, you agree to abide by our
21
+
[Code of Conduct](https://github.com/api-platform/docs#coc-ov-file). We expect all contributors to
22
+
foster a welcoming and inclusive environment.
21
23
22
24
## How to Contribute
23
25
24
-
1. Fork this repository by clicking the "Fork" button at the top right of the `api-platform/docs` repository page.
26
+
1. Fork this repository by clicking the "Fork" button at the top right of the `api-platform/docs`
27
+
repository page.
25
28
26
29
2. Clone the forked repository to your local machine:
Copy file name to clipboardExpand all lines: admin/authentication-support.md
+84-67Lines changed: 84 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,18 @@
2
2
3
3
API Platform Admin delegates the authentication support to React Admin.
4
4
5
-
Refer to the [Auth Provider Setup](https://marmelab.com/react-admin/Authentication.html) documentation for more information.
5
+
Refer to the [Auth Provider Setup](https://marmelab.com/react-admin/Authentication.html)
6
+
documentation for more information.
6
7
7
-
**Tip:** Once you have set up the authentication, you can also configure React Admin to perform client-side Authorization checks. Refer to the [Authorization](https://marmelab.com/react-admin/Permissions.html) documentation for more information.
8
+
**Tip:** Once you have set up the authentication, you can also configure React Admin to perform
9
+
client-side Authorization checks. Refer to the
10
+
[Authorization](https://marmelab.com/react-admin/Permissions.html) documentation for more
11
+
information.
8
12
9
13
## HydraAdmin
10
14
11
-
Enabling authentication support for [`<HydraAdmin>` component](./components.md#hydra) consists of a few parts, which need to be integrated together.
15
+
Enabling authentication support for [`<HydraAdmin>` component](./components.md#hydra) consists of a
16
+
few parts, which need to be integrated together.
12
17
13
18
In the following steps, we will see how to:
14
19
@@ -18,52 +23,54 @@ In the following steps, we will see how to:
18
23
19
24
### Make Authenticated Requests
20
25
21
-
First, we need to implement a `getHeaders` function, that will add the Bearer token from `localStorage` (if there is one) to the `Authorization` header.
26
+
First, we need to implement a `getHeaders` function, that will add the Bearer token from
27
+
`localStorage` (if there is one) to the `Authorization` header.
Then, we'll create a `<RedirectToLogin>` component, that will redirect users to the `/login` route if no token is available in the `localStorage`, and call the dataProvider's `introspect` function otherwise.
51
+
Then, we'll create a `<RedirectToLogin>` component, that will redirect users to the `/login` route
52
+
if no token is available in the `localStorage`, and call the dataProvider's `introspect` function
Now, we will extend the `parseHydraDocumentaion` function (imported from the [@api-platform/api-doc-parser](https://github.com/api-platform/api-doc-parser) library).
72
+
Now, we will extend the `parseHydraDocumentaion` function (imported from the
Now, we can initialize the Hydra data provider with the custom `fetchHydra` (with custom headers) and `apiDocumentationParser` functions created earlier.
101
+
Now, we can initialize the Hydra data provider with the custom `fetchHydra` (with custom headers)
102
+
and `apiDocumentationParser` functions created earlier.
For the implementation of the admin component, you can find a working example in the [API Platform's demo application](https://github.com/api-platform/demo/blob/4.0/pwa/components/admin/Admin.tsx).
177
+
For the implementation of the admin component, you can find a working example in the
This section explains how to set up and customize the [`<OpenApiAdmin>` component](./components.md/#openapi) to enable authentication.
182
+
This section explains how to set up and customize the
183
+
[`<OpenApiAdmin>` component](./components.md/#openapi) to enable authentication.
176
184
177
185
In the following steps, we will see how to:
178
186
179
187
- Make authenticated requests to the API (i.e. include the `Authorization` header)
180
-
- Implement an authProvider to redirect users to the login page if they are not authenticated, and clear expired tokens when encountering unauthorized `401` response
188
+
- Implement an authProvider to redirect users to the login page if they are not authenticated, and
189
+
clear expired tokens when encountering unauthorized `401` response
181
190
182
191
### Making Authenticated Requests
183
192
184
-
First, we need to create a custom `httpClient` to add authentication tokens (via the the `Authorization` HTTP header) to requests.
193
+
First, we need to create a custom `httpClient` to add authentication tokens (via the the
194
+
`Authorization` HTTP header) to requests.
185
195
186
-
We will then configure `openApiDataProvider` to use [`ra-data-simple-rest`](https://github.com/marmelab/react-admin/blob/master/packages/ra-data-simple-rest/README.md), a simple REST dataProvider for React Admin, and make it use the `httpClient` we created earlier.
196
+
We will then configure `openApiDataProvider` to use
**Note:** The `simpleRestProvider` provider expect the API to include a `Content-Range` header in the response. You can find more about the header syntax in the [Mozilla’s MDN documentation: Content-Range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range).
224
+
**Note:** The `simpleRestProvider` provider expect the API to include a `Content-Range` header in
225
+
the response. You can find more about the header syntax in the
**Note:** The `getAccessToken` function retrieves the JWT token stored in the browser's localStorage. Replace it with your own logic in case you don't store the token that way.
228
+
**Note:** The `getAccessToken` function retrieves the JWT token stored in the browser's
229
+
localStorage. Replace it with your own logic in case you don't store the token that way.
215
230
216
231
### Creating The AuthProvider
217
232
218
-
Now let's create and export an `authProvider` object that handles authentication and authorization logic.
233
+
Now let's create and export an `authProvider` object that handles authentication and authorization
0 commit comments