handlers

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoServer

func EchoServer(settings types.APISettings) *echo.Echo

func IsBlacklisted

func IsBlacklisted(kv types.Store) echo.MiddlewareFunc

IsBlacklisted - TODO comment

func IsManager

func IsManager(next echo.HandlerFunc) echo.HandlerFunc

IsManager - TODO comment

func IsReader

func IsReader(db *gorm.DB) echo.MiddlewareFunc

IsReader - TODO comment

func IsUpdater

func IsUpdater(next echo.HandlerFunc) echo.HandlerFunc

IsReader - TODO comment

Types

type Handler

type Handler struct {
	DB        *gorm.DB
	KV        types.Store
	Guacamole bool
}

EchoServer - TODO command @title Glim REST API @version 1.0 @description Glim REST API for login/logout, user and group operations. Users and groups require a Bearer Token (JWT) that you can retrieve using login. Please use the project's README for full information about how you can use this token with Swagger. @contact.name Miguel Cabrerizo @contact.url https://github.com/doncicuto/glim/issues @contact.email support@sologitops.com @license.name Apache 2.0 @license.url http://www.apache.org/licenses/LICENSE-2.0.html @BasePath /v1 @securityDefinitions.apikey Bearer @in header @name Authorization

func (*Handler) AddGroupMembers

func (h *Handler) AddGroupMembers(c echo.Context) error

AddGroupMembers - TODO comment @Summary Add members to a group @Description Add members to a group @Tags groups @Accept json @Produce json @Param id path int true "Group ID" @Param members body models.GroupMembers true "Group members body. The members property expect a comma-separated list of usernames e.g 'bob,sally' to be added to the group" @Success 200 {object} models.GroupInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups/{id}/members [post] @Security Bearer

func (*Handler) AddMembers

func (h *Handler) AddMembers(g *models.Group, members []string) error

AddMembers - TODO comment

func (*Handler) AddMembersOf

func (h *Handler) AddMembersOf(u *models.User, memberOf []string) error

AddMembersOf - TODO comment

func (*Handler) DeleteGroup

func (h *Handler) DeleteGroup(c echo.Context) error

DeleteGroup - TODO comment @Summary Delete a group @Description Delete a group @Tags groups @Accept json @Produce json @Param id path int true "Group ID" @Success 204 @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 406 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups/{id} [delete] @Security Bearer

func (*Handler) DeleteUser

func (h *Handler) DeleteUser(c echo.Context) error

DeleteUser - TODO comment @Summary Delete user account @Description Delete user account @Tags users @Accept json @Produce json @Param id path int true "User Account ID" @Success 204 @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 406 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /users/{id} [delete] @Security Bearer

func (*Handler) FindAllGroups

func (h *Handler) FindAllGroups(c echo.Context) error

FindAllGroups - TODO comment @Summary Find all groups @Description Find all groups @Tags groups @Accept json @Produce json @Success 200 {object} models.GroupInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups [get] @Security Bearer

func (*Handler) FindAllUsers

func (h *Handler) FindAllUsers(c echo.Context) error

FindAllUsers - TODO comment @Summary Find all users @Description Find all users @Tags users @Accept json @Produce json @Success 200 {object} models.UserInfo @Failure 500 {object} types.ErrorResponse @Router /users [get] @Security Bearer

func (*Handler) FindGIDFromGroupName

func (h *Handler) FindGIDFromGroupName(c echo.Context) error

FindGIDFromGroupName - TODO comment @Summary Find user by group @Description Find user by group @Tags users @Accept json @Produce json @Param group path string true "group" @Success 200 {object} models.GroupID @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups/{group}/gid [get] @Security Bearer

func (*Handler) FindGroupByID

func (h *Handler) FindGroupByID(c echo.Context) error

FindGroupByID - TODO comment @Summary Find group by id @Description Find group by id @Tags groups @Accept json @Produce json @Param id path int true "Group ID" @Success 200 {object} models.GroupInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups/{id} [get] @Security Bearer

func (*Handler) FindUIDFromUsername

func (h *Handler) FindUIDFromUsername(c echo.Context) error

FindUIDFromUsername - TODO comment @Summary Find user by username @Description Find user by username @Tags users @Accept json @Produce json @Param username path string true "username" @Success 200 {object} models.UserID @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /users/{username}/uid [get] @Security Bearer

func (*Handler) FindUserByID

func (h *Handler) FindUserByID(c echo.Context) error

FindUserByID - TODO comment @Summary Find user by id @Description Find user by id @Tags users @Accept json @Produce json @Param id path int true "User Account ID" @Success 200 {object} models.UserInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /users/{id} [get] @Security Bearer

func (*Handler) GuacamoleSupport

func (h *Handler) GuacamoleSupport(c echo.Context) error

GuacamoleSupport - Check if Apache Guacamole support is enabled @Summary Check if Apache Guacamole support is enabled @Description Get a boolean showing if Apache Guacamole support is enabled @Produce json @Success 200 {object} types.GuacamoleSupport @Failure 400 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /guacamole [get]

func (*Handler) Healthz

func (h *Handler) Healthz(c echo.Context) error

Healthz - Liveness probe @Summary Check if Glim is running @Description Get a boolean showing if Apache Guacamole support is enabled @Produce json @Success 204 @Failure 503 {object} types.ErrorResponse @Router /healthz [get]

func (*Handler) Login

func (h *Handler) Login(c echo.Context, settings types.APISettings) error

Login - TODO comment @Summary Log in to the API @Description Log in to the API and get JWT access and refresh tokens @Tags authentication @Accept json @Produce json @Param authentication body types.LoginBody true "Username and password" @Success 200 {object} types.TokenAuthentication @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /login [post]

func (*Handler) Logout

func (h *Handler) Logout(c echo.Context, settings types.APISettings) error

Logout - TODO comment @Summary Delete authentication tokens @Description Log out from the API @Tags authentication @Accept json @Produce json @Param tokens body types.Tokens true "Access and Refresh JWT tokens" @Success 204 @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /login/refresh_token [delete]

func (*Handler) Passwd

func (h *Handler) Passwd(c echo.Context) error

Passwd - TODO comment @Summary Change user account password @Description Change user account password @Tags users @Accept json @Produce json @Param id path int true "User Account ID" @Param password body models.JSONPasswdBody true "Password body" @Success 204 @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 403 {object} types.ErrorResponse @Failure 406 {object} types.ErrorResponse @Router /users/{id}/passwd [post] @Security Bearer

func (*Handler) Readyz

func (h *Handler) Readyz(c echo.Context) error

Healthz - Readiness probe @Summary Check if Glim is running @Description Get a boolean showing if Apache Guacamole support is enabled @Produce json @Success 204 @Router /readyz [get]

func (*Handler) Refresh

func (h *Handler) Refresh(c echo.Context, settings types.APISettings) error

Refresh API tokens @Summary Refresh authentication tokens @Description Get new JWT access and refresh tokens @Tags authentication @Accept json @Produce json @Param tokens body types.Tokens true "Access and Refresh JWT tokens" @Success 200 {object} types.TokenAuthentication @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /login/refresh_token [post]

func (*Handler) RemoveGroupMembers

func (h *Handler) RemoveGroupMembers(c echo.Context) error

RemoveGroupMembers - TODO comment @Summary Remove members from a group @Description Remove members from a group @Tags groups @Accept json @Produce json @Param id path int true "Group ID" @Param members body models.GroupMembers true "Group members body. The members property expect a comma-separated list of usernames e.g 'bob,sally' to be removed from the group" @Success 204 @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 406 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups/{id}/members [delete] @Security Bearer

func (*Handler) RemoveMembersOf

func (h *Handler) RemoveMembersOf(u *models.User, memberOf []string) error

RemoveMembersOf - TODO comment

func (*Handler) SaveGroup

func (h *Handler) SaveGroup(c echo.Context) error

SaveGroup - TODO comment @Summary Create a new group @Description Create a new group @Tags groups @Accept json @Produce json @Param group body models.JSONGroupBody true "Group body. Name is required. The members property expect a comma-separated list of usernames e.g 'bob,sally'. The replace property is not used in this command." @Success 200 {object} models.GroupInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 406 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups [post] @Security Bearer

func (*Handler) SaveUser

func (h *Handler) SaveUser(c echo.Context) error

SaveUser - TODO comment @Summary Create a new user @Description Create a new user in our database @Tags users @Accept json @Produce json @Param user body models.JSONUserBody true "User account body. Username is required. The members property expect a comma-separated list of group names e.g 'admin,devel' that you want the user be member of. Password property is optional, if set it will be the password for that user, if no password is sent the user account will be locked (user can not log in). Manager property if true will assign the Manager role. Readonly property if true will set this user for read-only usage (queries). Locked property if true will disable log in for that user. Remove and replace properties are not currently used." @Success 200 {object} models.UserInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 406 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /users [post] @Security Bearer

func (*Handler) UpdateGroup

func (h *Handler) UpdateGroup(c echo.Context) error

UpdateGroup - TODO comment @Summary Update group @Description Update group @Tags groups @Accept json @Produce json @Param id path int true "Group ID" @Param group body models.JSONGroupBody true "Group body. All properties are optional. The members property expect a comma-separated list of usernames e.g 'bob,sally'. The replace property if true will replace all members by those selected by the members property, if replace is false the member will be added to current members." @Success 200 {object} models.UserInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 406 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /groups/{id} [put] @Security Bearer

func (*Handler) UpdateUser

func (h *Handler) UpdateUser(c echo.Context) error

UpdateUser - TODO comment @Summary Update user account information @Description Update user account information @Tags users @Accept json @Produce json @Param id path int true "User Account ID" @Param user body models.JSONUserBody true "User account body. Username is required. The members property expect a comma-separated list of group names e.g 'admin,devel'. Password property is optional, if set it will be the password for that user, if no password is sent the user account will be locked (user can not log in). Manager property if true will assign the Manager role. Readonly property if true will set this user for read-only usage (queries). Locked property if true will disable log in for that user. Remove property if true will remove group membership from those specified in the members property. Remove property if true will replace group membership from those specified in the members property. Name property is not used" @Success 200 {object} models.UserInfo @Failure 400 {object} types.ErrorResponse @Failure 401 {object} types.ErrorResponse @Failure 404 {object} types.ErrorResponse @Failure 500 {object} types.ErrorResponse @Router /users/{id} [put] @Security Bearer

Jump to

Keyboard shortcuts

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