modulepackage
4.1.4
Repository: https://github.com/highlight/go-oauth2-redis.git
Documentation: pkg.go.dev
# README
Redis Storage for OAuth 2.0
Install
$ go get -u -v github.com/go-oauth2/redis/v4
Usage
package main
import (
"github.com/redis/go-redis/v9"
oredis "github.com/go-oauth2/redis/v4"
"github.com/go-oauth2/oauth2/v4/manage"
)
func main() {
manager := manage.NewDefaultManager()
// use redis token store
manager.MapTokenStorage(oredis.NewRedisStore(&redis.Options{
Addr: "127.0.0.1:6379",
DB: 15,
}))
// use redis cluster store
// manager.MapTokenStorage(oredis.NewRedisClusterStore(&redis.ClusterOptions{
// Addrs: []string{"127.0.0.1:6379"},
// DB: 15,
// }))
}
Testing
Testing requires a redis db. If you already have one, go ahead and run go test ./...
like normal.
If you don't already have one, or don't want to use it, you can run in docker with docker compose run --rm test && docker compose down
.
MIT License
Copyright (c) 2020 Lyric
# Functions
NewRedisClusterStore create an instance of a redis cluster store.
NewRedisClusterStoreWithCli create an instance of a redis cluster store.
NewRedisStore create an instance of a redis store.
NewRedisStoreWithCli create an instance of a redis store.
# Structs
TokenStore redis token store.