oauth2

package
v0.0.0-...-e98fe29 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2014 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	E_INVALID_REQUEST int = iota
	E_UNAUTHORIZED_CLIENT
	E_ACCESS_DENIED
	E_UNSUPPORTED_RESPONSE_TYPE
	E_SERVER_ERROR
	E_TEMPORARILY_UNAVAILABLE
	E_INVALID_CLIENT
	E_INVALID_GRANT
	E_INVALID_SCOPE
	E_UNSUPPORTED_GRANT_TYPE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthError

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

func NewAuthError

func NewAuthError(client *Client, code int, detail string) *AuthError

func (*AuthError) Code

func (ae *AuthError) Code() int

func (*AuthError) Error

func (ae *AuthError) Error() string

Implements the error api

func (*AuthError) ErrorString

func (ae *AuthError) ErrorString() string

type Client

type Client struct {
	Id          string
	Secret      string
	BaseUri     string
	Description string
}

func NewClient

func NewClient(id, secret, uri, des string) *Client

func (*Client) String

func (c *Client) String() string

type ClientStore

type ClientStore interface {
	Save(c *Client) (string, error)
	Remove(id string) error
	Read(id string) (*Client, error)
}

type FileClientStore

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

func NewFileClientStore

func NewFileClientStore(filename string) (*FileClientStore, error)

func (*FileClientStore) Read

func (s *FileClientStore) Read(id string) (*Client, error)

func (*FileClientStore) Remove

func (s *FileClientStore) Remove(id string) error

func (*FileClientStore) Save

func (s *FileClientStore) Save(c *Client) (string, error)

type Manager

type Manager struct {
	CodeLife         int64
	TokenLife        int64
	RefreshTokenLife int64
	AllowGetMethod   bool

	Storage *Storage

	ClientAuthFunc func(r *http.Request, c *Client) bool
}

func (*Manager) GenerateCode

func (m *Manager) GenerateCode(r *http.Request) (*Token, error)

func (*Manager) GenerateToken

func (m *Manager) GenerateToken(r *http.Request) (*Token, *Token, error)

func (*Manager) RedirectUrlWithCode

func (m *Manager) RedirectUrlWithCode(code *Token) (*url.URL, error)

func (*Manager) ResponseWithError

func (m *Manager) ResponseWithError(w http.ResponseWriter, err error) error

func (*Manager) ResponseWithToken

func (m *Manager) ResponseWithToken(w http.ResponseWriter,
	token *Token, userData map[string]interface{}) error

func (*Manager) SaveCode

func (m *Manager) SaveCode(code *Token) error

func (*Manager) SaveToken

func (m *Manager) SaveToken(token *Token) error

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Read

func (m *MemoryStore) Read(id string) interface{}

func (*MemoryStore) Remove

func (m *MemoryStore) Remove(id string)

func (*MemoryStore) Save

func (m *MemoryStore) Save(id string, data interface{})

type MemoryTokenStore

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

func NewTokenStore

func NewTokenStore() *MemoryTokenStore

func (*MemoryTokenStore) Read

func (m *MemoryTokenStore) Read(id string) (*Token, error)

func (*MemoryTokenStore) Remove

func (m *MemoryTokenStore) Remove(id string) error

func (*MemoryTokenStore) Save

func (m *MemoryTokenStore) Save(t *Token) (string, error)

type Storage

type Storage struct {
	Client       ClientStore
	Code         TokenStore
	Token        TokenStore
	RefreshToken TokenStore
}

type Token

type Token struct {
	Value       string
	ClientId    string
	Scope       string
	State       string
	RedirectUri string
	CreatedAt   int64
	Life        int64
	UserData    map[string]interface{}
}

func NewToken

func NewToken(clientId, scope, uri string,
	life int64) *Token

type TokenStore

type TokenStore interface {
	Save(t *Token) (string, error)
	Remove(id string) error
	Read(id string) (*Token, error)
}

Jump to

Keyboard shortcuts

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