Skip to content

Files

Latest commit

f1b38df · Apr 22, 2017

History

History
44 lines (36 loc) · 1.09 KB

README.md

File metadata and controls

44 lines (36 loc) · 1.09 KB

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()

    ...
}