o2r

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2018 License: MIT Imports: 6 Imported by: 0

README

Redis Storage for OAuth 2.0

Based on the redis token storage

License ReportCard GoDoc

Install

$ go get -u -v gopkg.in/go-oauth2/redis.v1

Usage

package main

import (
	"gopkg.in/go-oauth2/redis.v1"
	"gopkg.in/oauth2.v3/manage"
)

func main() {
	manager := manage.NewDefaultManager()
	// use redis token store
	manager.MustTokenStorage(redis.NewTokenStore(&redis.Config{
		Addr: "127.0.0.1:6379",
	}))

	// ...
}

MIT License

Copyright (c) 2016 Lyric

Documentation

Index

Constants

View Source
const RedisKeyOauth2Client = "oauth2_client"

Variables

This section is empty.

Functions

func NewTokenStore

func NewTokenStore(cfg *redis.Options) (ts oauth2.TokenStore, err error)

NewTokenStore Create a token store instance based on redis

Types

type ClientValue added in v1.2.0

type ClientValue struct {
	Secret string `bson:"secret" json:"secret"`
	Domain string `bson:"domain" json:"domain"`
	UserID string `bson:"user_id" json:"user_id"`
}

type RedisClientStore added in v1.2.0

type RedisClientStore struct {
	// contains filtered or unexported fields
}

RedisTokenStore redis token store

func NewClientStore added in v1.2.0

func NewClientStore(cfg *redis.Options) (clientStore *RedisClientStore, err error)

func (*RedisClientStore) GetByID added in v1.2.0

func (cs *RedisClientStore) GetByID(id string) (cli oauth2.ClientInfo, err error)

GetByID according to the ID for the client information

func (*RedisClientStore) Set added in v1.2.0

func (cs *RedisClientStore) Set(id string, cli oauth2.ClientInfo) (err error)

Set set client information

type RedisTokenStore added in v1.2.0

type RedisTokenStore struct {
	// contains filtered or unexported fields
}

RedisTokenStore redis token store

func (*RedisTokenStore) Create added in v1.2.0

func (rs *RedisTokenStore) Create(info oauth2.TokenInfo) (err error)

Create Create and store the new token information

func (*RedisTokenStore) GetByAccess added in v1.2.0

func (rs *RedisTokenStore) GetByAccess(access string) (ti oauth2.TokenInfo, err error)

GetByAccess Use the access token for token information data

func (*RedisTokenStore) GetByCode added in v1.2.0

func (rs *RedisTokenStore) GetByCode(code string) (ti oauth2.TokenInfo, err error)

GetByCode Use the authorization code for token information data

func (*RedisTokenStore) GetByRefresh added in v1.2.0

func (rs *RedisTokenStore) GetByRefresh(refresh string) (ti oauth2.TokenInfo, err error)

GetByRefresh Use the refresh token for token information data

func (*RedisTokenStore) RemoveByAccess added in v1.2.0

func (rs *RedisTokenStore) RemoveByAccess(access string) (err error)

RemoveByAccess Use the access token to delete the token information

func (*RedisTokenStore) RemoveByCode added in v1.2.0

func (rs *RedisTokenStore) RemoveByCode(code string) (err error)

RemoveByCode Use the authorization code to delete the token information

func (*RedisTokenStore) RemoveByRefresh added in v1.2.0

func (rs *RedisTokenStore) RemoveByRefresh(refresh string) (err error)

RemoveByRefresh Use the refresh token to delete the token information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL