Skip to content
A plugin for github.com/RichardKnop/go-oauth2-server that provides redis storage for sessions
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
redis
vendor/gopkg.in/boj/redistore.v1
LICENSE
README.md

README.md

Go redis-sessions

This is a plugin for github.com/RichardKnop/go-oauth2-server that provides redis storage for sessions. It wraps github.com/boj/redistore.

Installation

go get https://github.com/adam-hanna/redis-sessions

Usage

Within github.com/RichardKnop/go-oauth2-server/cmd/run_server.go

import (
    ...
    "github.com/adam-hanna/redis-sessions/redis"
    ...
)

// RunServer runs the app
func RunServer(configBackend string) error {
    ...

    // configure redis for session store
    sessionSecrets := make([][]byte, 1)
    sessionSecrets[0] = []byte(cnf.Session.Secret)
    redisConfig := redis.ConfigType{
        Size:           10,
        Network:        "tcp",
        Address:        ":6379",
        Password:       "",
        SessionSecrets: sessionSecrets,
    }

    // start the services
    services.UseSessionService(redis.NewService(cnf, redisConfig))
    if err := services.InitServices(cnf, db); err != nil {
        return err
    }
    defer services.CloseServices()

    ...
}
You can’t perform that action at this time.