oauth

package
v0.0.0-...-987a2ef Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidJSON = errors.New("Invalid JSON")
)

vars

Functions

This section is empty.

Types

type Client

type Client struct {
	ID          string     `json:"id" db:"id" ` // pk
	Secret      string     `json:"secret" db:"secret"`
	RedirectURI string     `json:"redirectURI" db:"redirect_uri" `
	Meta        ClientMeta `json:"meta,omitempty" db:"meta" `       // jsonb
	CreatedAt   time.Time  `json:"created,omitempty" db:"created" ` // time.Now()
}

Client of oauth2

func NewClient

func NewClient(id, secret, redirectURI string) (c *Client)

NewClient build a client

func (*Client) CopyFrom

func (c *Client) CopyFrom(other storage.Client)

CopyFrom ...

func (*Client) GetGrantTypes

func (c *Client) GetGrantTypes() []string

GetGrantTypes ...

func (*Client) GetId

func (c *Client) GetId() string

GetId oauth.Client

func (*Client) GetName

func (c *Client) GetName() string

GetName ...

func (*Client) GetRedirectUri

func (c *Client) GetRedirectUri() string

GetRedirectUri oauth.Client

func (*Client) GetResponseTypes

func (c *Client) GetResponseTypes() []string

GetResponseTypes ...

func (*Client) GetScopes

func (c *Client) GetScopes() []string

GetScopes ...

func (*Client) GetSecret

func (c *Client) GetSecret() string

GetSecret oauth.Client

func (*Client) GetUserData

func (c *Client) GetUserData() interface{}

GetUserData oauth.Client

func (*Client) String

func (c *Client) String() string

type ClientMeta

type ClientMeta struct {
	Name          string   `json:"name,omitempty"`
	GrantTypes    []string `json:"grant_types,omitempty"`    // AllowedGrantTypes
	ResponseTypes []string `json:"response_types,omitempty"` // AllowedResponseTypes
	Scopes        []string `json:"scopes,omitempty"`         // AllowedScopes
}

ClientMeta ...

func (*ClientMeta) Scan

func (m *ClientMeta) Scan(value interface{}) (err error)

Scan implements the sql.Scanner interface.

func (ClientMeta) Value

func (m ClientMeta) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type ClientSpec

type ClientSpec struct {
	Page   int      `json:"page,omitempty" form:"page"`
	Limit  int      `json:"limit,omitempty" form:"limit"`
	Orders []string `json:"order,omitempty" form:"order"`
	Total  int      `json:"total,omitempty"` // for set value

	CountOnly bool `json:"count,omitempty" form:"count"`
}

ClientSpec 查询参数

type JSONKV

type JSONKV map[string]interface{}

JSONKV ...

func ToJSONKV

func ToJSONKV(src interface{}) (JSONKV, error)

ToJSONKV ...

func (*JSONKV) Scan

func (m *JSONKV) Scan(value interface{}) (err error)

Scan implements the sql.Scanner interface.

func (JSONKV) Value

func (m JSONKV) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

func (JSONKV) WithKey

func (m JSONKV) WithKey(key string) (v interface{})

WithKey ...

type Scope

type Scope struct {
	Name        string `json:"name"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	IsDefault   bool   `json:"is_default,omitempty" db:"is_default"`
}

Scope ...

type Store

type Store interface {
	osin.Storage

	LoadClient(id string) (*Client, error)
	LoadClients(spec *ClientSpec) ([]Client, error)
	CountClients() uint
	SaveClient(client *Client) error
	RemoveClient(id string) error

	LoadScopes() (scopes []Scope, err error)
	IsAuthorized(clientID, username string) bool
	SaveAuthorized(clientID, username string) error
}

Store ...

Jump to

Keyboard shortcuts

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