provider

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: MIT Imports: 24 Imported by: 24

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

type CredChecker interface {
	Check(user, password string) (ok bool, err error)
}

CredChecker defines interface to check credentials

type CredCheckerFunc added in v0.2.0

type CredCheckerFunc func(user, password string) (ok bool, err error)

CredCheckerFunc type is an adapter to allow the use of ordinary functions as CredsChecker.

func (CredCheckerFunc) Check added in v0.2.0

func (f CredCheckerFunc) Check(user, password string) (ok bool, err error)

Check calls f(user,passwd)

type DevAuthServer

type DevAuthServer struct {
	lgr.L
	Provider  Oauth2Handler
	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 DirectHandler added in v0.2.0

type DirectHandler struct {
	lgr.L
	CredChecker  CredChecker
	ProviderName string
	TokenService TokenService
	Issuer       string
}

DirectHandler implements non-oauth2 provider authorizing user in traditional way with storage with users and hashes

func (DirectHandler) AuthHandler added in v0.2.0

func (p DirectHandler) AuthHandler(w http.ResponseWriter, r *http.Request)

AuthHandler doesn't do anything for direct login as it has no callbacks

func (DirectHandler) LoginHandler added in v0.2.0

func (p DirectHandler) LoginHandler(w http.ResponseWriter, r *http.Request)

LoginHandler checks "user" and "passwd" against data store and makes jwt if all passed GET /something?user=name&password=xyz&sess=[0|1]

func (DirectHandler) LogoutHandler added in v0.2.0

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

LogoutHandler - GET /logout

func (DirectHandler) Name added in v0.2.0

func (p DirectHandler) Name() string

Name of the handler

type Oauth2Handler added in v0.1.1

type Oauth2Handler struct {
	Params
	// contains filtered or unexported fields
}

Oauth2Handler implements /login, /callback and /logout handlers from aouth2 flow

func NewDev

func NewDev(p Params) Oauth2Handler

NewDev makes dev oauth2 provider for admin user

func NewFacebook

func NewFacebook(p Params) Oauth2Handler

NewFacebook makes facebook oauth2 provider

func NewGithub

func NewGithub(p Params) Oauth2Handler

NewGithub makes github oauth2 provider

func NewGoogle

func NewGoogle(p Params) Oauth2Handler

NewGoogle makes google oauth2 provider

func NewYandex

func NewYandex(p Params) Oauth2Handler

NewYandex makes yandex oauth2 provider

func (Oauth2Handler) AuthHandler added in v0.1.1

func (p Oauth2Handler) AuthHandler(w http.ResponseWriter, r *http.Request)

AuthHandler fills user info and redirects to "from" url. This is callback url redirected locally by browser GET /callback

func (Oauth2Handler) LoginHandler added in v0.1.1

func (p Oauth2Handler) LoginHandler(w http.ResponseWriter, r *http.Request)

LoginHandler - GET /login?from=redirect-back-url&site=siteID&session=1

func (Oauth2Handler) LogoutHandler added in v0.1.1

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

LogoutHandler - GET /logout

func (Oauth2Handler) Name added in v0.1.1

func (p Oauth2Handler) Name() string

Name returns provider name

type Params

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

Params to make initialized and ready to use provider

type Provider added in v0.1.1

type Provider interface {
	Name() string
	LoginHandler(w http.ResponseWriter, r *http.Request)
	AuthHandler(w http.ResponseWriter, r *http.Request)
	LogoutHandler(w http.ResponseWriter, r *http.Request)
}

Provider defines interface for auth handler

type Service

type Service struct {
	Provider
}

Service represents oauth2 provider. Adds Handler method multiplexing login, auth and logout requests

func NewService added in v0.1.1

func NewService(p Provider) Service

NewService makes service for given provider

func (Service) Handler

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

Handler returns auth routes for given provider

type TokenService

type TokenService interface {
	Parse(tokenString string) (claims token.Claims, err error)
	Set(w http.ResponseWriter, claims token.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