login

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Overview

package login contains an optional "login" (authentication) server that can be used. It offers a simple (in the future customizable) login form that sends username / password via POST formdata to a /login endpoint. The authentication server then issues a cookie-based session.

This package can be used to turn oauth2go in a more-or-less complete authentication service. If this package is not used, an external authentication page that establishes a web-session with the user is needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler() *handler

func WithBaseURL added in v0.5.10

func WithBaseURL(url string) handlerOption

func WithLoginPage

func WithLoginPage(opts ...handlerOption) oauth2.AuthorizationServerOption

func WithPassswordHasher added in v0.3.0

func WithPassswordHasher(pwh PasswordHasher) handlerOption

func WithUser

func WithUser(name string, password string) handlerOption

Types

type PasswordHasher added in v0.3.0

type PasswordHasher interface {
	// CompareHashAndPassword compares a hash and a password. If successful, no error is returned.
	CompareHashAndPassword(hash []byte, password []byte) (err error)

	// GenerateFromPassword generates a hash out of a password. opts can be used to supply
	// implementation specific parameters.
	GenerateFromPassword(password []byte, opts ...interface{}) (hash []byte, err error)
}

PasswordHasher is an interface that can be used to support different password hashing algorithms in our login server. Basically, two functions need to be implemented, one for creating a hash out of a password and one for comparing a hash with a password.

type User

type User struct {
	// The unique name of this user
	Name string

	// The (hashed) user password.
	PasswordHash string
}

User represents a user in our authentication server. It has a unique name and potentially other meta-data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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