admin

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package admin defines the admin controllers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyController added in v0.5.2

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

func NewAPIKeyController added in v0.5.2

func NewAPIKeyController(s models.Querier) *APIKeyController

func (*APIKeyController) CreateAPIKey added in v0.5.2

func (ctr *APIKeyController) CreateAPIKey(c echo.Context) error

CreateAPIKey creates a new API key @Summary Create new API key @Description Creates a new API key with specified scopes. The plain key is returned only once. @Tags admin @Accept json @Produce json @Param request body CreateAPIKeyRequest true "API key details" @Success 201 {object} CreateAPIKeyResponse @Security JWTBearerToken @Router /admin/api-keys [post]

func (*APIKeyController) DeleteAPIKey added in v0.5.2

func (ctr *APIKeyController) DeleteAPIKey(c echo.Context) error

DeleteAPIKey soft-deletes an API key @Summary Delete API key @Description Soft-deletes an API key, making it unusable @Tags admin @Produce json @Param id path int true "API Key ID" @Success 204 "No Content" @Security JWTBearerToken @Router /admin/api-keys/{id} [delete]

func (*APIKeyController) GetAPIKey added in v0.5.2

func (ctr *APIKeyController) GetAPIKey(c echo.Context) error

GetAPIKey returns a specific API key by ID @Summary Get API key @Description Returns details of a specific API key (without the actual key value) @Tags admin @Produce json @Param id path int true "API Key ID" @Success 200 {object} APIKeyResponse @Security JWTBearerToken @Router /admin/api-keys/{id} [get]

func (*APIKeyController) GetAvailableScopes added in v0.5.2

func (ctr *APIKeyController) GetAvailableScopes(c echo.Context) error

GetAvailableScopes returns all available API scopes @Summary Get available API scopes @Description Returns a list of all available API scopes that can be assigned to API keys @Tags admin @Produce json @Success 200 {array} ScopeInfo @Security JWTBearerToken @Router /admin/api-keys/scopes [get]

func (*APIKeyController) ListAPIKeys added in v0.5.2

func (ctr *APIKeyController) ListAPIKeys(c echo.Context) error

ListAPIKeys lists all active API keys @Summary List API keys @Description Returns all active API keys (without the actual key values) @Tags admin @Produce json @Success 200 {array} APIKeyResponse @Security JWTBearerToken @Router /admin/api-keys [get]

func (*APIKeyController) UpdateAPIKeyIPRestrictions added in v0.5.2

func (ctr *APIKeyController) UpdateAPIKeyIPRestrictions(c echo.Context) error

UpdateAPIKeyIPRestrictions updates the IP restrictions of an API key @Summary Update API key IP restrictions @Description Updates the IP restrictions (CIDR ranges) for an API key @Tags admin @Accept json @Produce json @Param id path int true "API Key ID" @Param request body UpdateAPIKeyIPRestrictionsRequest true "New IP restrictions" @Success 200 {object} APIKeyResponse @Security JWTBearerToken @Router /admin/api-keys/{id}/ip-restrictions [put]

func (*APIKeyController) UpdateAPIKeyScopes added in v0.5.2

func (ctr *APIKeyController) UpdateAPIKeyScopes(c echo.Context) error

UpdateAPIKeyScopes updates the scopes of an API key @Summary Update API key scopes @Description Updates the permission scopes for an API key @Tags admin @Accept json @Produce json @Param id path int true "API Key ID" @Param request body UpdateAPIKeyScopesRequest true "New scopes" @Success 200 {object} APIKeyResponse @Security JWTBearerToken @Router /admin/api-keys/{id}/scopes [put]

type APIKeyResponse added in v0.5.2

type APIKeyResponse struct {
	ID             int32    `json:"id"`
	Name           string   `json:"name"`
	Description    string   `json:"description,omitempty"`
	Scopes         []string `json:"scopes"`
	IPRestrictions []string `json:"ip_restrictions,omitempty"`
	CreatedBy      int32    `json:"created_by"`
	CreatedAt      int32    `json:"created_at"`
	LastUsedAt     *int32   `json:"last_used_at,omitempty"`
	ExpiresAt      *int32   `json:"expires_at,omitempty"`
}

APIKeyResponse represents an API key without the actual key value

type CreateAPIKeyRequest added in v0.5.2

type CreateAPIKeyRequest struct {
	Name           string   `json:"name"                 validate:"required,min=3,max=255"`
	Description    string   `json:"description"          validate:"max=1000"`
	Scopes         []string `json:"scopes"               validate:"required,validscopes"`
	IPRestrictions []string `json:"ip_restrictions,omitempty" validate:"omitempty,dive,cidr"`
	ExpiresAt      *int32   `json:"expires_at,omitempty"`
}

CreateAPIKeyRequest represents the request to create a new API key

type CreateAPIKeyResponse added in v0.5.2

type CreateAPIKeyResponse struct {
	ID             int32    `json:"id"`
	Name           string   `json:"name"`
	Key            string   `json:"key"` // Only shown once!
	Scopes         []string `json:"scopes"`
	IPRestrictions []string `json:"ip_restrictions,omitempty"`
	CreatedAt      int32    `json:"created_at"`
	ExpiresAt      *int32   `json:"expires_at,omitempty"`
	Warning        string   `json:"warning"`
}

CreateAPIKeyResponse represents the response when creating an API key

type RoleController

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

RoleController is a struct that holds the service

func NewAdminRoleController

func NewAdminRoleController(s models.Querier) *RoleController

NewAdminRoleController creates a new RoleController

func (*RoleController) AddUsersToRole

func (ctr *RoleController) AddUsersToRole(c echo.Context) error

AddUsersToRole adds a role to a user @Summary Assign users to role @Description Assigns users to a role @Tags admin @Accept json @Produce json @Param id path int true "Role ID" @Param data body UsersRequest true "List of usernames" @Success 200 @Router /admin/roles/{id}/users [post] @Security JWTBearerToken

func (*RoleController) CreateRole

func (ctr *RoleController) CreateRole(c echo.Context) error

CreateRole creates a new role @Summary Create role @Description Creates a new role @Tags admin @Accept json @Produce json @Param data body RoleDataRequest true "Role data" @Success 201 {object} RoleCreateResponse @Router /admin/roles [post] @Security JWTBearerToken

func (*RoleController) DeleteRole

func (ctr *RoleController) DeleteRole(c echo.Context) error

DeleteRole deletes a role @Summary Delete role @Description Deletes a role @Tags admin @Param id path int true "Role ID" @Success 200 @Router /admin/roles/{id} [delete] @Security JWTBearerToken

func (*RoleController) GetRoles

func (ctr *RoleController) GetRoles(c echo.Context) error

GetRoles returns a list of roles @Summary List roles @Description Returns a list of roles @Tags admin @Produce json @Success 200 {object} RoleListResponse @Router /admin/roles [get] @Security JWTBearerToken

func (*RoleController) RemoveUsersFromRole

func (ctr *RoleController) RemoveUsersFromRole(c echo.Context) error

RemoveUsersFromRole removes a role from a user @Summary Remove users from role @Description Removes users from a role @Tags admin @Accept json @Produce json @Param id path int true "Role ID" @Param data body UsersRequest true "List of usernames" @Success 200 @Router /admin/roles/{id}/users [delete] @Security JWTBearerToken

func (*RoleController) UpdateRole

func (ctr *RoleController) UpdateRole(c echo.Context) error

UpdateRole updates a role @Summary Update role @Description Updates a role @Tags admin @Accept json @Produce json @Param id path int true "Role ID" @Param data body RoleDataRequest true "Role data" @Success 200 {object} roleUpdateResponse @Router /admin/roles/{id} [put] @Security JWTBearerToken

type RoleCreateResponse

type RoleCreateResponse struct {
	ID int32 `json:"id"`
}

RoleCreateResponse is a struct that holds the response for the create role endpoint

type RoleDataRequest

type RoleDataRequest struct {
	Name        string `json:"name"        validate:"required,min=3,max=50" extensions:"x-order=0"`
	Description string `json:"description" validate:"min=3,max=255"         extensions:"x-order=1"`
}

RoleDataRequest is a struct that holds the request for the create role endpoint

type RoleListResponse

type RoleListResponse struct {
	Roles []RoleNameResponse `json:"roles,omitempty"`
}

RoleListResponse is a struct that holds the response for the list roles endpoint

type RoleNameResponse

type RoleNameResponse struct {
	ID          int32  `json:"id"          extensions:"x-order=0"`
	Name        string `json:"name"        extensions:"x-order=1"`
	Description string `json:"description" extensions:"x-order=2"`
}

RoleNameResponse is a struct that holds the response for the role name endpoint

type ScopeInfo added in v0.5.2

type ScopeInfo struct {
	Scope       string `json:"scope"`
	Resource    string `json:"resource"`
	Action      string `json:"action"`
	Description string `json:"description"`
}

ScopeInfo represents information about an API scope

type UpdateAPIKeyIPRestrictionsRequest added in v0.5.2

type UpdateAPIKeyIPRestrictionsRequest struct {
	IPRestrictions []string `json:"ip_restrictions" validate:"dive,cidr"`
}

UpdateAPIKeyIPRestrictionsRequest represents the request to update API key IP restrictions

type UpdateAPIKeyScopesRequest added in v0.5.2

type UpdateAPIKeyScopesRequest struct {
	Scopes []string `json:"scopes" validate:"required,validscopes"`
}

UpdateAPIKeyScopesRequest represents the request to update API key scopes

type UsersRequest

type UsersRequest struct {
	Users []string `json:"users" validate:"required"`
}

UsersRequest is a struct that holds the request for the assign users to role endpoint

Jump to

Keyboard shortcuts

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