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: README.md
+60-14Lines changed: 60 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,6 @@ http {
61
61
62
62
## Roadmap
63
63
64
-
* Add support for session id generator plugins (maybe you don't want to use random data, and want UUID or maybe some kind of database identifier instead).
65
64
* Add support for different schemes:
66
65
* Encrypt-and-MAC: The ciphertext is generated by encrypting the plaintext and then appending a MAC of the plaintext.
67
66
* MAC-then-encrypt: The ciphertext is generated by appending a MAC to the plaintext and then encrypting everything.
@@ -475,6 +474,51 @@ To configure session to use your adapter, you can do so with Nginx configuration
475
474
set $session_encoder base64;
476
475
```
477
476
477
+
## Pluggable Session Identifier Ganerators
478
+
479
+
With version 2.12 we started to support pluggable session identifier generators in `lua-resty-session`.
480
+
Right now we support only one type of generator, and that is:
481
+
482
+
*`random`
483
+
484
+
If you want to write your own session identifier generator, you need to implement one function:
485
+
486
+
*`string function(config)`
487
+
488
+
(the config is actually a session instance =
489
+
490
+
You have to place your generator inside `resty.session.identifiers` for auto-loader to work.
491
+
492
+
To configure session to use your generator, you can do so with Nginx configuration (or in Lua code):
493
+
494
+
```nginx
495
+
set $session_identifier_generator random;
496
+
```
497
+
498
+
#### Random Sesssion Identifier Generator
499
+
500
+
Random generator uses `lua-resty-string`'s (an OpenResty core library) OpenSSL based cryptographically
501
+
safe random generator.
502
+
503
+
Random generator can be selected with configuration:
504
+
505
+
```nginx
506
+
set $session_identifier random;
507
+
```
508
+
509
+
Additionally you can configure Random generator with these settings:
510
+
511
+
```nginx
512
+
set $session_random_length 16;
513
+
```
514
+
515
+
Here follows the description of each setting:
516
+
517
+
**length**
518
+
519
+
`session.random.length` holds the length of the `session.id`. By default it is 16 bytes.
520
+
This can be configured with Nginx `set $session_random_length 16;`.
521
+
478
522
## Lua API
479
523
480
524
### Functions and Methods
@@ -532,7 +576,7 @@ expiration time stored in a cookie.
532
576
```lua
533
577
localsession=require"resty.session".open()
534
578
-- Set some options (overwriting the defaults or nginx configuration variables)
0 commit comments