oauth

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

vars

Functions

func StringFromMeta added in v0.12.0

func StringFromMeta(kv interface{}, key string) string

StringFromMeta ...

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) GetGrantTypes added in v0.12.0

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

GetGrantTypes ...

func (*Client) GetId

func (c *Client) GetId() string

GetId oauth.Client

func (*Client) GetName added in v0.12.0

func (c *Client) GetName() string

GetName ...

func (*Client) GetRedirectUri

func (c *Client) GetRedirectUri() string

GetRedirectUri oauth.Client

func (*Client) GetResponseTypes added in v0.12.0

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

GetResponseTypes ...

func (*Client) GetScopes added in v0.12.0

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 added in v0.12.0

func (c *Client) String() string

type ClientMeta added in v0.12.0

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 added in v0.12.0

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

Scan implements the sql.Scanner interface.

func (ClientMeta) Value added in v0.12.0

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

Value implements the driver.Valuer interface.

type ClientSpec added in v0.9.0

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 added in v0.12.0

type JSONKV map[string]interface{}

JSONKV ...

func ToJSONKV added in v0.12.0

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

ToJSONKV ...

func (*JSONKV) Scan added in v0.12.0

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

Scan implements the sql.Scanner interface.

func (JSONKV) Value added in v0.12.0

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

Value implements the driver.Valuer interface.

func (JSONKV) WithKey added in v0.12.0

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

WithKey ...

type OSINStore added in v0.9.0

type OSINStore 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
}

OSINStore ...

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 ...

Jump to

Keyboard shortcuts

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