auth

package
v0.0.0-...-e0434a4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package auth contains types for working with non blank user names. User always has a non blank name. OptionalUser will either have a non blank name or no value.

Index

Constants

View Source
const (
	AuthInfoContextKey contextKey = "AuthInfo"
)

Variables

This section is empty.

Functions

func CreateContextWithAuthInfo

func CreateContextWithAuthInfo(ctx context.Context, info AggregatorUserInfo) context.Context

func ErrAuthInfoMissing

func ErrAuthInfoMissing(authInfo AggregatorUserInfo) error

func ErrAuthInfoUsernameIsMissing

func ErrAuthInfoUsernameIsMissing(authInfo AggregatorUserInfo) error

func IsErrAuthInfoMissing

func IsErrAuthInfoMissing(e error) bool

func IsErrAuthInfoUsernameIsMissing

func IsErrAuthInfoUsernameIsMissing(e error) bool

Types

type AggregatorUserInfo

type AggregatorUserInfo struct {
	User   string
	Groups []string
	Extra  map[string][]string
}

func RetrieveAuthInfoFromContext

func RetrieveAuthInfoFromContext(ctx context.Context) (AggregatorUserInfo, bool)

type AuthenticationMode

type AuthenticationMode string

type InfoError

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

func (*InfoError) AuthInfo

func (e *InfoError) AuthInfo() AggregatorUserInfo

func (*InfoError) Error

func (e *InfoError) Error() string

type OptionalUser

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

the possibility of a user

func MaybeNamed

func MaybeNamed(name string) OptionalUser

store an non blank user name inside the optional user

func MaybeRequestUser

func MaybeRequestUser(r *http.Request) OptionalUser

func NoUser

func NoUser() OptionalUser

convenience function for building no user

func ToOptionalUser

func ToOptionalUser(user User) OptionalUser

weaken the User type into an OptionalUser type.

func (OptionalUser) NameOrElse

func (user OptionalUser) NameOrElse(defaultValue string) string

access the user name of an optional user. If no name is present return the default value

type User

type User interface {
	Name() string
}

use an interface to expose the user type hiding in privateUser

func Named

func Named(name string) (User, error)

func RequestUser

func RequestUser(r *http.Request) (User, error)

Jump to

Keyboard shortcuts

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