oauth

package
v0.0.0-...-e647751 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewError

func NewError(c int, m string) error

NewError wraps a message in a Error object.

Types

type Client

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

Client is an oauth client.

func New

func New(ctx context.Context, cfg *Config) (*Client, error)

New creates a new client

func (*Client) HandleCallback

func (c *Client) HandleCallback(w nethttp.ResponseWriter, r *nethttp.Request, us *sessions.Session, sessionID string) (*oauth2.Token, error)

HandleCallback handles the callback from the oauth server.

func (*Client) HandleLogin

func (c *Client) HandleLogin(w nethttp.ResponseWriter, r *nethttp.Request, us *sessions.Session, sessionID string) error

HandleLogin sends the user to the oauth login server.

type Config

type Config struct {
	CallbackURL  string
	ServerURL    string
	ClientID     string
	ClientSecret string
}

Config contains configuration for the oauth client.

type Error

type Error struct {
	Code    int
	Message string
}

Error is an oauth specific error.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message as a string.

type SessionKey

type SessionKey int

SessionKey is a key used for storing data in a web session.

const (
	// SessionKeyState contains the state sent to the oauth server.
	SessionKeyState SessionKey = iota
	// SessionKeyCode contains the code sent to the oauth server.
	SessionKeyCode
	// SessionKeyNonce contains the nonce sent to the oauth server.
	SessionKeyNonce
)

Jump to

Keyboard shortcuts

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