Skip to content

A plugin for github.com/RichardKnop/go-oauth2-server that provides redis storage for sessions

License

Notifications You must be signed in to change notification settings

adam-hanna/redis-sessions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

    ...
}

About

A plugin for github.com/RichardKnop/go-oauth2-server that provides redis storage for sessions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages