Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security example for app.keys #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ yarn add koa-redis

`koa-redis` works with [koa-session](https://github.com/koajs/session) (a basic session middleware for koa).

For more examples, please see the [examples folder of `koa-session`](https://github.com/koajs/session/tree/master/example).
For more examples, please see the [examples folder of `koa-session`](https://github.com/koajs/session/blob/master/Readme.md#example).

### Basic

```js
const session = require('koa-session');
const redisStore = require('koa-redis');
const Keygrip = require('keygrip');
const koa = require('koa');

const app = koa();
app.keys = ['keys', 'keykeys'];
app.keys = new Keygrip(['insert 64 bytes random string', 'insert another 64 bytes random string'], 'sha512', 'base64');
app.use(session({
store: redisStore({
// Options specified here
Expand Down Expand Up @@ -117,10 +118,11 @@ app.listen(8080);
```js
const session = require('koa-session');
const redisStore = require('koa-redis');
const Keygrip = require('keygrip');
const koa = require('koa');

const app = koa();
app.keys = ['keys', 'keykeys'];
app.keys = new Keygrip(['insert 64 bytes random string', 'insert another 64 bytes random string'], 'sha512', 'base64');
app.use(session({
store: redisStore({
// Options specified here
Expand All @@ -142,10 +144,11 @@ app.use(session({
```js
const session = require('koa-session');
const redisStore = require('koa-redis');
const Keygrip = require('keygrip');
const koa = require('koa');

const app = koa();
app.keys = ['keys', 'keykeys'];
app.keys = new Keygrip(['insert 64 bytes random string', 'insert another 64 bytes random string'], 'sha512', 'base64');
app.use(session({
store: redisStore({
// Options specified here
Expand Down Expand Up @@ -206,9 +209,10 @@ const session = require('koa-session');
const redisStore = require('koa-redis')({
// Options specified here
});
const Keygrip = require('keygrip');
const app = require('koa')();

app.keys = ['keys', 'keykeys'];
app.keys = new Keygrip(['insert 64 bytes random string', 'insert another 64 bytes random string'], 'sha512');
app.use(session({
store: redisStore
}, app));
Expand Down
3 changes: 2 additions & 1 deletion benchmark/koa.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const Keygrip = require('keygrip');
const Koa = require('koa');
const session = require('koa-session');
const redisStore = require('../src');

const app = new Koa();

app.keys = ['keys', 'keykeys'];
app.keys = new Keygrip(['aibiizae0oetheiz9naepeiz6Ogheepowaehia4kengahz2oic4xep0be2fu0dah', 'Aew0heishieSeivekoosharooPei8aeg4phacheegh3ieLai9xahPhaet5Ezoo7p'], 'sha512');
if (process.argv[2] !== 'nosession') {
app.use(
session(
Expand Down