provider

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2018 License: MIT Imports: 23 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvatarSaver

type AvatarSaver interface {
	Put(u token.User) (avatarURL string, err error)
}

AvatarSaver defines minimal interface to save avatar

type DevAuthServer

type DevAuthServer struct {
	logger.L
	Provider  Service
	Automatic bool
	// contains filtered or unexported fields
}

DevAuthServer is a fake oauth server for development it provides stand-alone server running on its own port and pretending to be the real oauth2. It also provides Dev Provider the same way as normal providers do, i.e. like github, google and others. can run in interactive and non-interactive mode. In interactive mode login attempts will show login form to select desired user name, this is the mode used for development. Non-interactive mode for tests only.

func (*DevAuthServer) Run

func (d *DevAuthServer) Run(ctx context.Context)

Run oauth2 dev server on port devAuthPort

func (*DevAuthServer) Shutdown

func (d *DevAuthServer) Shutdown()

Shutdown oauth2 dev server

type Params

type Params struct {
	logger.L
	URL         string
	JwtService  TokenService
	AvatarSaver AvatarSaver
	Cid         string
	Csecret     string
	Issuer      string
}

Params to make initialized and ready to use provider

type Service

type Service struct {
	Params
	Name        string
	RedirectURL string
	InfoURL     string
	Endpoint    oauth2.Endpoint
	Scopes      []string
	MapUser     func(userData, []byte) token.User // map info from InfoURL to User
	// contains filtered or unexported fields
}

Service represents oauth2 provider

func NewDev

func NewDev(p Params) Service

NewDev makes dev oauth2 provider for admin user

func NewFacebook

func NewFacebook(p Params) Service

NewFacebook makes facebook oauth2 provider

func NewGithub

func NewGithub(p Params) Service

NewGithub makes github oauth2 provider

func NewGoogle

func NewGoogle(p Params) Service

NewGoogle makes google oauth2 provider

func NewYandex

func NewYandex(p Params) Service

NewYandex makes yandex oauth2 provider

func (Service) Handler

func (p Service) Handler(w http.ResponseWriter, r *http.Request)

Handler returns auth routes for given provider

func (Service) LogoutHandler

func (p Service) LogoutHandler(w http.ResponseWriter, r *http.Request)

LogoutHandler - GET /logout

type TokenService

type TokenService interface {
	Parse(tokenString string) (claims token.Claims, err error)
	Set(w http.ResponseWriter, claims token.Claims) error
	Get(r *http.Request) (claims token.Claims, token string, err error)
	Reset(w http.ResponseWriter)
}

TokenService defines interface accessing tokens

Jump to

Keyboard shortcuts

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