user

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIKeyIDHeader represents the header used to provide an API key ID.
	APIKeyIDHeader = "X-API-KEY-ID" // #nosec

	// APIKeySecretHeader represents the header used to provide an API key
	// secret.
	APIKeySecretHeader = "X-API-KEY-SECRET" // #nosec

	// SessionApprovedHeader represents the header used to indicate a client if
	// a session is approved or not. When a user has enabled TFA, sessions need
	// be approved by providing a TFA passcode to the session validation
	// endpoint. If TFA is not enabled, sessions will be approved on creation.
	SessionApprovedHeader = "X-SESSION-APPROVED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handlers

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

Handlers represents a group of http handlers in charge of handling users operations.

func NewHandlers

func NewHandlers(
	ctx context.Context,
	userManager hub.UserManager,
	apiKeyManager hub.APIKeyManager,
	cfg *viper.Viper,
) (*Handlers, error)

NewHandlers creates a new Handlers instance.

func (*Handlers) ApproveSession added in v0.20.0

func (h *Handlers) ApproveSession(w http.ResponseWriter, r *http.Request)

ApproveSession is an http handler used to approve a session. When a user has enabled TFA, sessions created after users identify themselves with their credentials need to be approved to make them valid by providing a valid TFA passcode.

func (*Handlers) BasicAuth

func (h *Handlers) BasicAuth(next http.Handler) http.Handler

BasicAuth is a middleware that provides basic auth support.

func (*Handlers) CheckAvailability

func (h *Handlers) CheckAvailability(w http.ResponseWriter, r *http.Request)

CheckAvailability is an http handler that checks the availability of a given value for the provided resource kind.

func (*Handlers) CheckPasswordStrength added in v0.19.0

func (h *Handlers) CheckPasswordStrength(w http.ResponseWriter, r *http.Request)

CheckPasswordStrength is an http handler that checks the strength of the password provided

func (*Handlers) DeleteUser added in v1.1.0

func (h *Handlers) DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser is an http handler used to delete the account of the user doing the request.

func (*Handlers) DisableTFA added in v0.20.0

func (h *Handlers) DisableTFA(w http.ResponseWriter, r *http.Request)

DisableTFA is an http handler used to disable two-factor authentication.

func (*Handlers) EnableTFA added in v0.20.0

func (h *Handlers) EnableTFA(w http.ResponseWriter, r *http.Request)

EnableTFA is an http handler used to enable two-factor authentication.

func (*Handlers) GetProfile

func (h *Handlers) GetProfile(w http.ResponseWriter, r *http.Request)

GetProfile is an http handler used to get a logged in user profile.

func (*Handlers) InjectUserID

func (h *Handlers) InjectUserID(next http.Handler) http.Handler

InjectUserID is a middleware that injects the id of the user doing the request into the request context when a valid session id is provided.

func (*Handlers) Login

func (h *Handlers) Login(w http.ResponseWriter, r *http.Request)

Login is an http handler used to log a user in.

func (*Handlers) Logout

func (h *Handlers) Logout(w http.ResponseWriter, r *http.Request)

Logout is an http handler used to log a user out.

func (*Handlers) OauthCallback

func (h *Handlers) OauthCallback(w http.ResponseWriter, r *http.Request)

OauthCallback is an http handler in charge of completing the oauth authentication process, registering the user if needed.

func (*Handlers) OauthRedirect

func (h *Handlers) OauthRedirect(w http.ResponseWriter, r *http.Request)

OauthRedirect is an http handler that redirects the user to the oauth provider to proceed with the authorization.

func (*Handlers) RegisterDeleteUserCode added in v1.1.0

func (h *Handlers) RegisterDeleteUserCode(w http.ResponseWriter, r *http.Request)

RegisterDeleteUserCode is an http handler used to register a code to delete a user account. The code will be emailed to the address provided.

func (*Handlers) RegisterPasswordResetCode

func (h *Handlers) RegisterPasswordResetCode(w http.ResponseWriter, r *http.Request)

RegisterPasswordResetCode is an http handler used to register a code to reset the password. The code will be emailed to the address provided.

func (*Handlers) RegisterUser

func (h *Handlers) RegisterUser(w http.ResponseWriter, r *http.Request)

RegisterUser is an http handler used to register a user in the hub database.

func (*Handlers) RequireLogin

func (h *Handlers) RequireLogin(next http.Handler) http.Handler

RequireLogin is a middleware that verifies if a user is logged in.

func (*Handlers) ResetPassword

func (h *Handlers) ResetPassword(w http.ResponseWriter, r *http.Request)

ResetPassword is an http handler used to reset the user's password.

func (*Handlers) SetupTFA added in v0.20.0

func (h *Handlers) SetupTFA(w http.ResponseWriter, r *http.Request)

SetupTFA is an http handler used to setup two-factor authentication.

func (*Handlers) UpdatePassword

func (h *Handlers) UpdatePassword(w http.ResponseWriter, r *http.Request)

UpdatePassword is an http handler used to update the password in the hub database.

func (*Handlers) UpdateProfile

func (h *Handlers) UpdateProfile(w http.ResponseWriter, r *http.Request)

UpdateProfile is an http handler used to update the user in the hub database.

func (*Handlers) VerifyEmail

func (h *Handlers) VerifyEmail(w http.ResponseWriter, r *http.Request)

VerifyEmail is an http handler used to verify a user's email address.

func (*Handlers) VerifyPasswordResetCode

func (h *Handlers) VerifyPasswordResetCode(w http.ResponseWriter, r *http.Request)

VerifyPasswordResetCode is an http handler used to verify a reset password code.

type OauthState

type OauthState struct {
	Random      string
	RedirectURL string
}

OauthState represents the state of an oauth authorization session, used to increase the security of the process and to restore the state of the application.

func NewOauthState

func NewOauthState(s string) (*OauthState, error)

NewOauthState creates a new OauthState instance from the string representation provided.

func (*OauthState) String

func (s *OauthState) String() string

String returns an OauthState instance as a string.

Jump to

Keyboard shortcuts

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