🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

github.com/ankr-network/oauth2-redis

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ankr-network/oauth2-redis

v1.1.0
Version published
Created

Redis Storage for OAuth 2.0

forked from go-oauth2/redis, supported get by user id and remove by user id.

Install

$ go get -u -v github.com/Ankr-network/oauth2-redis

Usage

package main

import (
	"github.com/go-redis/redis"
	oredis "github.com/Ankr-network/oauth2-redis"
	"gopkg.in/oauth2.v3/manage"
)

func main() {
	manager := manage.NewDefaultManager()
	
	tokenStore := oredis.NewRedisStore(&redis.Options{
		Addr: "127.0.0.1:6379",
		DB: 15,
	})
	// use redis token store
	manager.MapTokenStorage(tokenStore)

	// get token by user id
	// t, _ := tokenStore.GetByUID("test") // get token info by user id
	// _ := tokenStore.RemoveByUID("test") // remove access token and refresh token by uid

	// use redis cluster store
	// manager.MapTokenStorage(oredis.NewRedisClusterStore(&redis.ClusterOptions{
	// 	Addrs: []string{"127.0.0.1:6379"},
	// 	DB: 15,
	// }))
}

FAQs

Package last updated on 17 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts