@@ -31,15 +31,10 @@ RUN make && make install
3131WORKDIR /var/lib/postgresql
3232```
3333
34- Then rebuild:
34+ Then rebuild the Postgres imageand recreate the container :
3535
3636``` sh
3737docker compose build postgres
38- ```
39-
40- And recreate the running container:
41-
42- ``` sh
4338docker compose up -d postgres
4439```
4540
@@ -249,14 +244,57 @@ applied.
249244Add the auth schema to Postgres in ` compose.yaml ` :
250245
251246``` yaml
252- PGRST_DB_SCHEMAS : api,auth
247+ postgrest :
248+ environment :
249+ PGRST_DB_SCHEMAS : api,auth
250+ ` ` `
251+
252+ And recreate the PostgREST container:
253+
254+ ` ` ` sh
255+ docker compose up -d postgrest
256+ ```
257+
258+ ## ✅ Usage
259+
260+ To use the ` auth ` schema, requests [ must include a
261+ header] ( https://docs.postgrest.org/en/stable/references/api/schemas.html#multiple-schemas ) .
262+
263+ GET and HEAD requests should include the header:
264+
265+ ```
266+ Accept-Profile: auth
253267```
254268
255- ✅ Usage
269+ Other methods (POST, PATCH, PUT and DELETE) should include:
256270
257- Explain that all auth endpoints must have a certain header.
271+ ```
272+ Content-Profile: auth
273+ ```
274+
275+ ### Examples
276+
277+ Login:
278+
279+ ``` sh
280+ curl \
281+ -H " Content-Profile: auth" \
282+ -H " Content-Type: application/json" \
283+ --data ' {"user_": "demo", "pass": "demo"}' \
284+ http://localhost/rpc/login
285+ ```
258286
259- Show example of using each endpoint.
287+ Get the refresh token inserted when logged in:
288+
289+ ``` sh
290+ bin/postgres psql -c ' select token from auth.refresh_token order by created_at desc limit 1'
291+ ```
292+
293+ Refresh the access token and extract the new token from the Set-Cookie header:
294+
295+ ``` sh
296+ export ACCESS_TOKEN=$( curl --silent -i -X POST -H ' Cookie: refresh_token=' $REFRESH_TOKEN ' ; HttpOnly' http://localhost/rpc/refresh_token | sed -nE ' s/^Set-Cookie: access_token=([^;]*).*/\1/p' )
297+ ```
260298
261299- POST-ing a user.
262300- ` /rpc/login `
0 commit comments