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
To initiate the session you can use this middleware:
27
+
1. Trigger session, make a GET request to: `/api/csrf-header`. This will return a header with the session key and an optional header with CSRF token `XSRF-TOKEN`.
28
+
The header name could be configured in: `stateless.header`
Now the server will return 419 (Page expired code). Unless you send back a request header named: `X-CSRF-TOKEN` with the value received by the first GET request in the `XSRF-TOKEN` header.
43
38
44
-
Any GET request with `stateless.session` or `stateless.csrf` will return back a response header with key
45
-
configured in `config('stateless.header')`.
39
+
That's it.
46
40
47
-
This header should be sent back to the server with the same name, so the SessionManager could find the right session.
41
+
At this point you have CSRF protection.
48
42
49
-
If the request should perform a csrf check, just add a `X-CSRF-TOKEN` with the value received in the previous request
50
-
under `XSRF-TOKEN` header name.
43
+
And you can play with `SessionManager` and use the `session()` helper to store/get information (e.g. flash sessions).
51
44
52
45
## Config
53
46
54
-
The API will inject into headers the session key. The session key name could be configured in the:
47
+
The lifetime and other options could be set as before in the `session` file.
48
+
49
+
The `VerifyHeaderCsrfToken` and `StartStatelessSession` middlewares will inject into headers the session key.
0 commit comments