1
0
Fork 0

Document cookie transport

This commit is contained in:
Alan Plum 2016-05-20 16:39:11 +02:00
parent 27b56a9343
commit c5f559eb1c
No known key found for this signature in database
GPG Key ID: 8ED72A9A323B6EFD
1 changed files with 26 additions and 8 deletions

View File

@ -2,7 +2,24 @@
`const cookieTransport = require('@arangodb/foxx/sessions/transports/cookie');` `const cookieTransport = require('@arangodb/foxx/sessions/transports/cookie');`
TODO The cookie transport stores session identifiers in cookies on the request and response object.
**Examples**
```js
// Pass in a secure secret from the Foxx configuration
const secret = module.context.configuration.cookieSecret;
const sessions = sessionsMiddleware({
storage: module.context.collection('sessions'),
transport: cookieTransport({
name: 'FOXXSESSID',
ttl: 60 * 60 * 24 * 7, // one week in seconds
algorithm: 'sha256',
secret: secret
})
});
module.context.use(sessions);
```
!SECTION Creating a transport !SECTION Creating a transport
@ -18,20 +35,21 @@ Creates a [Transport][TRANSPORT] that can be used in the sessions middleware.
* **name**: `string` (Default: `"sid"`) * **name**: `string` (Default: `"sid"`)
TODO The name of the cookie.
* **ttl**: `number` (optional) * **ttl**: `number` (optional)
TODO Cookie lifetime in seconds.
* **secret**: `string` (optional)
TODO
* **algorithm**: `string` (optional) * **algorithm**: `string` (optional)
TODO The algorithm used to sign and verify the cookie. If no algorithm is specified, the cookie will not be signed or verified. See the [cookie method on the response object][RESPONSE].
* **secret**: `string` (optional)
Secret to use for the signed cookie. Will be ignored if no algorithm is provided.
If a string is passed instead of an options object, it will be interpreted as the *name* option. If a string is passed instead of an options object, it will be interpreted as the *name* option.
[RESPONSE]: ../../Router/Response.md
[TRANSPORT]: ./README.md [TRANSPORT]: ./README.md