auth

package
v0.0.0-...-4f898de Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

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

Basic config for authentication

func NewBasic

func NewBasic(userStore docshelf.UserStore) Basic

NewBasic returns a new Basic authenticator.

func (Basic) Authenticate

func (b Basic) Authenticate(ctx context.Context, email, token string) (docshelf.User, error)

Authenticate implements the docshelf.Authenticator interface. It looks the user up by email and hashes their given password using bcrypt. If the hash matches what was returned from the userStore, the login is successful.

type Claims

type Claims struct {
	jwt.StandardClaims

	Email string `json:"email"`
	Name  string `json:"name"`
}

Claims represent claimed data embedded in an ouath access token.

type Github

type Github struct {
	ClientID     string
	ClientSecret string
	// contains filtered or unexported fields
}

Github config for authenticating through oauth.

func NewGithub

func NewGithub(userStore docshelf.UserStore, clientID, clientSecret string) Github

NewGithub creates a new Github authenticator with the given clientID and clientSecret.

func (Github) Authenticate

func (g Github) Authenticate(ctx context.Context, email, token string) (docshelf.User, error)

Authenticate implements the dochself.Authenticator interface. It takes a temporary auth code and uses it to request an access token from github. If authorization is successful, the primary email for the authorized user is used to login or. The email argument is completely ignored, but required to implement the docshelf.Authenticator interface.

type Google

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

Google config for oauth authentication.

func NewGoogle

func NewGoogle(userStore docshelf.UserStore, clientID, clientSecret string) Google

NewGoogle returns a new Google oauth config.

func (Google) Authenticate

func (g Google) Authenticate(ctx context.Context, email, token string) (docshelf.User, error)

Authenticate implements the docshelf.Authenticator interface. The email is ignored and the token is expected to be a google auth ID token. The token is validated using google's public keys and the email and name are extracted from the verified JWT claims. If the ID token is valid, then auth is successful.

Jump to

Keyboard shortcuts

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