Set the session key from an env variable
This commit is contained in:
parent
fe36b1d23c
commit
b89616a904
2 changed files with 11 additions and 3 deletions
11
README.md
11
README.md
|
@ -29,12 +29,19 @@ $ echo "CREATE EXTENSION pg_trgm;"|psql trantor
|
||||||
|
|
||||||
Now you can install Trantor itself:
|
Now you can install Trantor itself:
|
||||||
```
|
```
|
||||||
# go get gitlab.com/trantor/trantor
|
$ git clone gitlab.com/trantor/trantor
|
||||||
|
$ cd trantor
|
||||||
|
$ go build
|
||||||
|
```
|
||||||
|
|
||||||
|
Generate a random session key:
|
||||||
|
```
|
||||||
|
$ base64 /dev/random | head -c 50
|
||||||
```
|
```
|
||||||
|
|
||||||
You can run it (using `/var/lib/trantor` for storage):
|
You can run it (using `/var/lib/trantor` for storage):
|
||||||
```
|
```
|
||||||
# $GOPATH/bin/trantor -assets $GOPATH/src/pkg/gitlab.com/trantor/trantor/ -store /var/lib/trantor
|
$ SESSION_KEY=<session> ./trantor -store /var/lib/trantor
|
||||||
```
|
```
|
||||||
|
|
||||||
The first time you run it, the database will be initialized. To initialize an admin user, include the -set-admin-user and -set-admin-pass variables
|
The first time you run it, the database will be initialized. To initialize an admin user, include the -set-admin-user and -set-admin-pass variables
|
||||||
|
|
|
@ -3,13 +3,14 @@ package trantor
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/gorilla/securecookie"
|
"github.com/gorilla/securecookie"
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
"gitlab.com/trantor/trantor/lib/database"
|
"gitlab.com/trantor/trantor/lib/database"
|
||||||
)
|
)
|
||||||
|
|
||||||
var sesStore = sessions.NewCookieStore(securecookie.GenerateRandomKey(64))
|
var sesStore = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))
|
||||||
|
|
||||||
type Notification struct {
|
type Notification struct {
|
||||||
Title string
|
Title string
|
||||||
|
|
Reference in a new issue