Documentation
¶
Overview ¶
Package apitoken implements CRUD HTTP endpoints for shared API tokens. It is intentionally free of any internal/server import; error responses go through module/apierr, which exists to avoid that cycle.
Index ¶
- type APITokenInfo
- type Handler
- func (h *Handler) Create(c *gin.Context)
- func (h *Handler) Delete(c *gin.Context)
- func (h *Handler) Disable(c *gin.Context)
- func (h *Handler) Enable(c *gin.Context)
- func (h *Handler) Get(c *gin.Context)
- func (h *Handler) GrantPermission(c *gin.Context)
- func (h *Handler) List(c *gin.Context)
- func (h *Handler) MoveToTeam(c *gin.Context)
- func (h *Handler) Regenerate(c *gin.Context)
- func (h *Handler) RegisterRoutes(rt *module.Routes)
- func (h *Handler) RevokePermission(c *gin.Context)
- type TokenCreateRequest
- type TokenCreateResponse
- type TokenListQuery
- type TokenListResponse
- type TokenMoveRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APITokenInfo ¶
type APITokenInfo struct {
TokenID string `json:"token_id"`
UserID string `json:"user_id"`
TeamID string `json:"team_id"`
DisplayName string `json:"display_name"`
Enabled bool `json:"enabled"`
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
CreatedBy string `json:"created_by,omitempty"`
// Permissions is this account's granted capability set. Empty means none;
// unknown future keys are returned verbatim.
Permissions []string `json:"permissions"`
}
APITokenInfo represents token metadata (without the raw token string).
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles API-token HTTP requests.
func NewHandler ¶
func NewHandler(store *db.APITokenStore) *Handler
NewHandler creates a Handler backed by the given store.
func (*Handler) GrantPermission ¶ added in v1.261203.1
GrantPermission handles PUT /tokens/:token_id/permissions/:permission.
func (*Handler) MoveToTeam ¶ added in v0.260827.1
MoveToTeam handles PUT /tokens/:token_id/team.
func (*Handler) Regenerate ¶
Regenerate handles POST /tokens/:token_id/regenerate — keeps the same token_id but issues a new token string.
func (*Handler) RegisterRoutes ¶ added in v1.261002.1
func (*Handler) RevokePermission ¶ added in v1.261203.1
RevokePermission handles DELETE /tokens/:token_id/permissions/:permission.
type TokenCreateRequest ¶
type TokenCreateRequest struct {
DisplayName string `json:"display_name" binding:"required"`
TeamID string `json:"team_id,omitempty"`
}
TokenCreateRequest is the request body for creating a new API token.
type TokenCreateResponse ¶
type TokenCreateResponse struct {
Token string `json:"token"`
TokenID string `json:"token_id"`
UserID string `json:"user_id"`
TeamID string `json:"team_id"`
DisplayName string `json:"display_name"`
CreatedAt time.Time `json:"created_at"`
}
TokenCreateResponse is returned after a token is created or regenerated.
type TokenListQuery ¶ added in v0.260716.1
type TokenListQuery struct {
UserID string `form:"user_id" json:"user_id,omitempty"`
TeamID string `form:"team_id" json:"team_id,omitempty"`
Enabled *bool `form:"enabled" json:"enabled,omitempty"`
Limit int `form:"limit" json:"limit,omitempty"`
Offset int `form:"offset" json:"offset,omitempty"`
}
TokenListQuery describes the optional filters accepted by GET /tokens.
type TokenListResponse ¶
type TokenListResponse struct {
Tokens []APITokenInfo `json:"tokens"`
Total int64 `json:"total"`
}
TokenListResponse is the response for listing tokens.
type TokenMoveRequest ¶ added in v0.260827.1
type TokenMoveRequest struct {
TeamID string `json:"team_id" binding:"required"`
}
TokenMoveRequest moves an existing sharing key to another team. The raw key remains unchanged, but its authorization scope changes immediately.