auth

package
v0.0.0-...-403b7d6 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeEmail

func ChangeEmail(env *handler.Environment) httprouter.Handle

ChangeEmail starts the process of setting a new e-mail address for the logged-in user. The change needs to be confirmed before it takes effect. The response body is always empty.

Endpoint:

/auth/email

Methods:

PUT

Possible status codes:

202 - Request was accepted
400 - Malformed or missing form data
401 - Insufficient permission
422 - Not a valid e-mail address
500 - Internal server error

Example input:

email=new@email.address

func ChangePassword

func ChangePassword(env *handler.Environment) httprouter.Handle

ChangePassword sets a new password for the logged-in user. Unlike ResetConfirm, it doesn't require a token, but it checks the requesting user's identity and expects the user's current password. If successful, the password is changed. The response body is always empty.

This is the route that should be called when users try to change their passwords from within their profile settings.

Endpoint:

/auth/pass

Methods:

PUT

Possible status codes:

200 - Password change successful
400 - Malformed or missing form data
401 - Insufficient permission
404 - User doesn't exist
422 - New password is too weak
500 - Internal server error

Example input:

passold=topsecret&passnew=topsecret123

func Confirm

func Confirm(env *handler.Environment) httprouter.Handle

Confirm completes the user registration by confirming the sign-up token. If successful, the associated token is deleted and the user is able to sign in. The response body is always empty.

Endpoint:

/auth/confirm

Methods:

PUT

Possible status codes:

200 - Registration complete
400 - Malformed or missing form data
404 - User or token doesn't exist
500 - Internal server error

Example input:

token=178a6ee3f1da299fed940aa2d7

func LocalLogin

func LocalLogin(env *handler.Environment) httprouter.Handle

LocaLogin handles login for users with local accounts as opposed to users who authenticate with SSO services like OAuth. The response body is always empty.

Endpoint:

/auth/local

Methods:

POST

Possible status codes:

200 - Login successful
400 - Malformed or missing form data
401 - Unsuccessful login attempt
500 - Internal server error

Example input:

email=user@example.com&pass=topsecret

func LocalLogout

func LocalLogout(env *handler.Environment) httprouter.Handle

LocaLogout handles logout for users with local accounts as opposed to users who authenticate with SSO services like OAuth. The response body is always empty.

Endpoint:

/auth/local

Methods:

DELETE

Possible status codes:

200 - Logout successful
404 - Session not found, user is not logged in
500 - Internal server error

func ResetConfirm

func ResetConfirm(env *handler.Environment) httprouter.Handle

ResetConfirm completes a password reset request. If successful, the associated token is deleted and the password is changed. The response body is always empty.

Endpoint:

/auth/reset

Methods:

PUT

Possible status codes:

200 - Password reset successful
400 - Malformed or missing form data
404 - User or token doesn't exist
422 - New password is too weak
500 - Internal server error

Example input:

email=user@example.com&pass=topsecret

func ResetRequest

func ResetRequest(env *handler.Environment) httprouter.Handle

ResetRequest creates a new password reset request and sends a notification to the user with instructions on how to complete the request. The response body is always empty. For security reasons, this is one of a handful of functions that return success status codes even when technically failing. This is done to make user enumeration more difficult.

Endpoint:

/auth/reset

Methods:

POST

Possible status codes:

202 - Request was accepted
400 - Malformed or missing form data
500 - Internal server error

Example input:

email=user@example.com

Types

This section is empty.

Jump to

Keyboard shortcuts

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