mauth

package module
v0.0.0-...-c5ffe20 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: MIT Imports: 10 Imported by: 0

README

mauth

loov.dev/mauth is a package for managing OAuth2 sessions. It's largely based on github.com/markbates/goth/gothic, however without any global variables.

Documentation

Overview

Package mauth implements OAuth2 authentication for providers in github.com/markbates/goth/providers. It's largely based on github.com/markbates/goth/gothic, however, without global state.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidProvider is returned when an invalid provider is used in BeginLogin or FinishLogin.
	ErrInvalidProvider = errors.New("invalid provider")
)

Functions

This section is empty.

Types

type Provider

type Provider = goth.Provider

Provider is a single OAuth2 provider from github.com/markbates/provider.

type Providers

type Providers = goth.Providers

Providers is a list of OAuth2 providers.

type Sessions

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

Sessions manages sessions for multiple goth.Provider-s.

func New

func New(store sessions.Store, name string, providers Providers) *Sessions

New creates a new authentication manager.

func NewWithCookieStore

func NewWithCookieStore(secret []byte, providers Providers) *Sessions

NewWithCookieStore creates a new authentication manager that uses CookieStore with default name.

func (*Sessions) BeginLogin

func (s *Sessions) BeginLogin(providerName string, w http.ResponseWriter, r *http.Request) (url string, _ error)

BeginLogin redirects request to provider OAuth login page.

If it returns error, it has not redirected the page.

func (*Sessions) FinishLogin

func (s *Sessions) FinishLogin(providerName string, w http.ResponseWriter, r *http.Request) (User, error)

FinishLogin should be called as a callback after authentication.

func (*Sessions) Logout

func (s *Sessions) Logout(w http.ResponseWriter, r *http.Request) error

Logout clears any associated sessions.

func (*Sessions) Providers

func (s *Sessions) Providers() Providers

Providers returns the list of providers.

type User

type User = goth.User

User is authentication information about the user.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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