Documentation
¶
Index ¶
- func AdminOrganizationByIDHandler(s store.Storer) http.HandlerFunc
- func AdminOrganizationsHandler(s store.Storer) http.HandlerFunc
- func AdminSignupInvitesHandler(s store.Storer, cfg *config.Config) http.HandlerFunc
- func AdminUsersHandler(s store.Storer, cfg *config.Config) http.HandlerFunc
- func AuthConfigHandler(cfg *config.Config) http.HandlerFunc
- func DeleteUserHandler(s store.Storer) http.HandlerFunc
- func ExportCSVHandler(s store.Storer) http.Handler
- func NewAutoAllocateUseCase(s store.Storer) usecase.Interactor
- func NewCSVResponseEncoder() nethttp.ResponseEncoder
- func NewCreateAllocationUseCase(s store.Storer) usecase.Interactor
- func NewCreateBlockUseCase(s store.Storer) usecase.Interactor
- func NewCreateEnvironmentUseCase(s store.Storer) usecase.Interactor
- func NewCreatePoolUseCase(s store.Storer) usecase.Interactor
- func NewCreateReservedBlockUseCase(s store.Storer) usecase.Interactor
- func NewCreateTokenUseCase(s store.Storer) usecase.Interactor
- func NewDeleteAllocationUseCase(s store.Storer) usecase.Interactor
- func NewDeleteBlockUseCase(s store.Storer) usecase.Interactor
- func NewDeleteEnvironmentUseCase(s store.Storer) usecase.Interactor
- func NewDeletePoolUseCase(s store.Storer) usecase.Interactor
- func NewDeleteReservedBlockUseCase(s store.Storer) usecase.Interactor
- func NewDeleteTokenUseCase(s store.Storer) usecase.Interactor
- func NewExportCSVUseCase(s store.Storer) usecase.Interactor
- func NewGetAllocationUseCase(s store.Storer) usecase.Interactor
- func NewGetBlockUsageUseCase(s store.Storer) usecase.Interactor
- func NewGetBlockUseCase(s store.Storer) usecase.Interactor
- func NewGetEnvironmentUseCase(s store.Storer) usecase.Interactor
- func NewGetPoolUseCase(s store.Storer) usecase.Interactor
- func NewGetSetupStatusUseCase(s store.Storer, cfg *config.Config) usecase.Interactor
- func NewListAllocationsUseCase(s store.Storer) usecase.Interactor
- func NewListBlocksUseCase(s store.Storer) usecase.Interactor
- func NewListEnvironmentsUseCase(s store.Storer) usecase.Interactor
- func NewListPoolsUseCase(s store.Storer) usecase.Interactor
- func NewListReservedBlocksUseCase(s store.Storer) usecase.Interactor
- func NewListTokensUseCase(s store.Storer) usecase.Interactor
- func NewLoginUseCase(s store.Storer, limiter *auth.LoginAttemptLimiter, cfg *config.Config) usecase.Interactor
- func NewLogoutUseCase(s store.Storer) usecase.Interactor
- func NewMeUseCase() usecase.Interactor
- func NewPostSetupUseCase(s store.Storer, cfg *config.Config) usecase.Interactor
- func NewSuggestBlockCIDRUseCase(s store.Storer) usecase.Interactor
- func NewSuggestPoolBlockCIDRUseCase(s store.Storer) usecase.Interactor
- func NewTourCompletedUseCase(s store.Storer) usecase.Interactor
- func NewUpdateAllocationUseCase(s store.Storer) usecase.Interactor
- func NewUpdateBlockUseCase(s store.Storer) usecase.Interactor
- func NewUpdateEnvironmentUseCase(s store.Storer) usecase.Interactor
- func NewUpdatePoolUseCase(s store.Storer) usecase.Interactor
- func NewUpdateReservedBlockUseCase(s store.Storer) usecase.Interactor
- func OAuthCallbackHandler(s store.Storer, cfg *config.Config, registry *oauth.ProviderRegistry) http.HandlerFunc
- func OAuthStartHandler(cfg *config.Config, registry *oauth.ProviderRegistry) http.HandlerFunc
- func RegisterWithInviteHandler(s store.Storer) http.HandlerFunc
- func ResolveStaticDir() string
- func RevokeSignupInviteHandler(s store.Storer) http.HandlerFunc
- func Static(dir string, next http.Handler) http.Handler
- func Unauthorized(appOrigin string, next http.Handler) http.Handler
- func UpdateUserOrganizationHandler(s store.Storer) http.HandlerFunc
- func UpdateUserRoleHandler(s store.Storer) http.HandlerFunc
- func ValidateSignupInviteHandler(s store.Storer) http.HandlerFunc
- type AuthConfigResponse
- type CreateOrganizationRequest
- type CreateSignupInviteRequest
- type CreateSignupInviteResponse
- type CreateTokenRequest
- type CreateUserRequest
- type OrganizationResponse
- type RegisterWithInviteRequest
- type SignupInviteResponse
- type UpdateOrganizationRequest
- type UpdateUserOrganizationRequest
- type UpdateUserRoleRequest
- type UserResponse
- type ValidateSignupInviteResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminOrganizationByIDHandler ¶
func AdminOrganizationByIDHandler(s store.Storer) http.HandlerFunc
AdminOrganizationByIDHandler handles PATCH (update name) and DELETE for /api/admin/organizations/:id. Global admin only.
func AdminOrganizationsHandler ¶
func AdminOrganizationsHandler(s store.Storer) http.HandlerFunc
AdminOrganizationsHandler handles GET (list) and POST (create) /api/admin/organizations. Global admin only.
func AdminSignupInvitesHandler ¶
AdminSignupInvitesHandler handles GET (list) and POST (create) /api/admin/signup-invites. Admin only.
func AdminUsersHandler ¶
AdminUsersHandler handles GET (list) and POST (create) /api/admin/users. Admin only.
func AuthConfigHandler ¶
func AuthConfigHandler(cfg *config.Config) http.HandlerFunc
AuthConfigHandler returns auth-related config for the frontend (enabled OAuth provider IDs).
func DeleteUserHandler ¶
func DeleteUserHandler(s store.Storer) http.HandlerFunc
DeleteUserHandler handles DELETE /api/admin/users/:id. Admin only.
func ExportCSVHandler ¶
ExportCSVHandler returns an http.Handler that writes CSV directly to the response. Use this when the use-case + custom encoder chain does not write the body (e.g. empty download).
func NewAutoAllocateUseCase ¶
func NewAutoAllocateUseCase(s store.Storer) usecase.Interactor
AutoAllocate handler: find the next available CIDR in a block via bin-packing and create the allocation.
func NewCSVResponseEncoder ¶
func NewCSVResponseEncoder() nethttp.ResponseEncoder
NewCSVResponseEncoder returns a ResponseEncoder that writes exportCSVOutput.Body as text/csv.
func NewCreateAllocationUseCase ¶
func NewCreateAllocationUseCase(s store.Storer) usecase.Interactor
CreateAllocation handler
func NewCreateBlockUseCase ¶
func NewCreateBlockUseCase(s store.Storer) usecase.Interactor
CreateBlock handler
func NewCreateEnvironmentUseCase ¶
func NewCreateEnvironmentUseCase(s store.Storer) usecase.Interactor
CreateEnvironment handler
func NewCreatePoolUseCase ¶
func NewCreatePoolUseCase(s store.Storer) usecase.Interactor
CreatePool handler
func NewCreateReservedBlockUseCase ¶
func NewCreateReservedBlockUseCase(s store.Storer) usecase.Interactor
NewCreateReservedBlockUseCase returns a use case for POST /api/reserved-blocks. Admin only.
func NewCreateTokenUseCase ¶
func NewCreateTokenUseCase(s store.Storer) usecase.Interactor
NewCreateTokenUseCase returns a use case for POST /api/auth/me/tokens. Only admins can create tokens.
func NewDeleteAllocationUseCase ¶
func NewDeleteAllocationUseCase(s store.Storer) usecase.Interactor
DeleteAllocation handler
func NewDeleteBlockUseCase ¶
func NewDeleteBlockUseCase(s store.Storer) usecase.Interactor
DeleteBlock handler. Cascades: deletes all allocations in this block, then the block.
func NewDeleteEnvironmentUseCase ¶
func NewDeleteEnvironmentUseCase(s store.Storer) usecase.Interactor
DeleteEnvironment handler
func NewDeletePoolUseCase ¶
func NewDeletePoolUseCase(s store.Storer) usecase.Interactor
DeletePool handler
func NewDeleteReservedBlockUseCase ¶
func NewDeleteReservedBlockUseCase(s store.Storer) usecase.Interactor
NewDeleteReservedBlockUseCase returns a use case for DELETE /api/reserved-blocks/:id. Admin only.
func NewDeleteTokenUseCase ¶
func NewDeleteTokenUseCase(s store.Storer) usecase.Interactor
NewDeleteTokenUseCase returns a use case for DELETE /api/auth/me/tokens/:id.
func NewExportCSVUseCase ¶
func NewExportCSVUseCase(s store.Storer) usecase.Interactor
NewExportCSVUseCase returns a use case for GET /api/export/csv.
func NewGetAllocationUseCase ¶
func NewGetAllocationUseCase(s store.Storer) usecase.Interactor
GetAllocation handler
func NewGetBlockUsageUseCase ¶
func NewGetBlockUsageUseCase(s store.Storer) usecase.Interactor
GetBlockUsage handler
func NewGetBlockUseCase ¶
func NewGetBlockUseCase(s store.Storer) usecase.Interactor
GetBlock handler
func NewGetEnvironmentUseCase ¶
func NewGetEnvironmentUseCase(s store.Storer) usecase.Interactor
GetEnvironment handler returns the environment with its blocks.
func NewGetSetupStatusUseCase ¶
NewGetSetupStatusUseCase returns a use case for GET /api/setup/status. When INITIAL_ADMIN_EMAIL is set, setup is skipped (admin is or will be created at startup).
func NewListAllocationsUseCase ¶
func NewListAllocationsUseCase(s store.Storer) usecase.Interactor
ListAllocations handler
func NewListBlocksUseCase ¶
func NewListBlocksUseCase(s store.Storer) usecase.Interactor
ListBlocks handler
func NewListEnvironmentsUseCase ¶
func NewListEnvironmentsUseCase(s store.Storer) usecase.Interactor
ListEnvironments handler
func NewListPoolsUseCase ¶
func NewListPoolsUseCase(s store.Storer) usecase.Interactor
ListPools handler (by environment or by organization)
func NewListReservedBlocksUseCase ¶
func NewListReservedBlocksUseCase(s store.Storer) usecase.Interactor
NewListReservedBlocksUseCase returns a use case for GET /api/reserved-blocks. Admin only.
func NewListTokensUseCase ¶
func NewListTokensUseCase(s store.Storer) usecase.Interactor
NewListTokensUseCase returns a use case for GET /api/auth/me/tokens.
func NewLoginUseCase ¶
func NewLoginUseCase(s store.Storer, limiter *auth.LoginAttemptLimiter, cfg *config.Config) usecase.Interactor
NewLoginUseCase returns a use case for POST /api/auth/login. If limiter is non-nil, failed login attempts per client IP are limited to mitigate brute-force. If cfg has any OAuth providers enabled, password login is rejected except when the user is the only one in the system (e.g. right after setup).
func NewLogoutUseCase ¶
func NewLogoutUseCase(s store.Storer) usecase.Interactor
NewLogoutUseCase returns a use case for POST /api/auth/logout.
func NewMeUseCase ¶
func NewMeUseCase() usecase.Interactor
NewMeUseCase returns a use case for GET /api/auth/me.
func NewPostSetupUseCase ¶
NewPostSetupUseCase returns a use case for POST /api/setup. Creates the first admin only when no users exist. When OAuth is enabled, password is optional; the admin will sign in via OAuth after setup.
func NewSuggestBlockCIDRUseCase ¶
func NewSuggestBlockCIDRUseCase(s store.Storer) usecase.Interactor
SuggestBlockCIDR handler returns a suggested CIDR for the block at the given prefix length, considering existing allocations and bin-packing to fill gaps first.
func NewSuggestPoolBlockCIDRUseCase ¶
func NewSuggestPoolBlockCIDRUseCase(s store.Storer) usecase.Interactor
SuggestPoolBlockCIDR returns a suggested CIDR for a new block in the pool at the given prefix length, considering existing blocks in that pool and reserved ranges overlapping the pool.
func NewTourCompletedUseCase ¶
func NewTourCompletedUseCase(s store.Storer) usecase.Interactor
NewTourCompletedUseCase returns a use case for POST /api/auth/me/tour-completed.
func NewUpdateAllocationUseCase ¶
func NewUpdateAllocationUseCase(s store.Storer) usecase.Interactor
UpdateAllocation handler
func NewUpdateBlockUseCase ¶
func NewUpdateBlockUseCase(s store.Storer) usecase.Interactor
UpdateBlock handler
func NewUpdateEnvironmentUseCase ¶
func NewUpdateEnvironmentUseCase(s store.Storer) usecase.Interactor
UpdateEnvironment handler
func NewUpdatePoolUseCase ¶
func NewUpdatePoolUseCase(s store.Storer) usecase.Interactor
UpdatePool handler
func NewUpdateReservedBlockUseCase ¶
func NewUpdateReservedBlockUseCase(s store.Storer) usecase.Interactor
NewUpdateReservedBlockUseCase returns a use case for PUT /api/reserved-blocks/:id. Admin only.
func OAuthCallbackHandler ¶
func OAuthCallbackHandler(s store.Storer, cfg *config.Config, registry *oauth.ProviderRegistry) http.HandlerFunc
OAuthCallbackHandler exchanges code for token, fetches user info, then creates/links user and sets session. Path: /api/auth/oauth/:provider/callback.
func OAuthStartHandler ¶
func OAuthStartHandler(cfg *config.Config, registry *oauth.ProviderRegistry) http.HandlerFunc
OAuthStartHandler redirects to the provider's OAuth authorize URL. Path: /api/auth/oauth/:provider/start. Query: invite_token (optional).
func RegisterWithInviteHandler ¶
func RegisterWithInviteHandler(s store.Storer) http.HandlerFunc
RegisterWithInviteHandler handles POST /api/signup/register. No auth. Creates user, consumes invite, sets session.
func ResolveStaticDir ¶
func ResolveStaticDir() string
ResolveStaticDir returns a directory containing index.html for the SPA, or "" if none found. Tries STATIC_DIR, then web/dist relative to CWD or executable, so signup links (GET /) work.
func RevokeSignupInviteHandler ¶
func RevokeSignupInviteHandler(s store.Storer) http.HandlerFunc
RevokeSignupInviteHandler handles DELETE /api/admin/signup-invites/:id. Admin only.
func Static ¶
Static serves API/docs from next, everything else from dir (SPA fallback to index.html).
func Unauthorized ¶
Unauthorized returns 401 Unauthorized with a simple HTML body for non-API, non-docs requests (used when APP_ORIGIN is set so the app is served from another origin).
func UpdateUserOrganizationHandler ¶
func UpdateUserOrganizationHandler(s store.Storer) http.HandlerFunc
UpdateUserOrganizationHandler handles PATCH /api/admin/users/:id/organization. Global admin only.
func UpdateUserRoleHandler ¶
func UpdateUserRoleHandler(s store.Storer) http.HandlerFunc
UpdateUserRoleHandler handles PATCH /api/admin/users/:id/role. Admin only.
func ValidateSignupInviteHandler ¶
func ValidateSignupInviteHandler(s store.Storer) http.HandlerFunc
ValidateSignupInviteHandler handles GET /api/signup/validate?token=xxx. No auth.
Types ¶
type AuthConfigResponse ¶
type AuthConfigResponse struct {
OAuthProviders []string `json:"oauth_providers"`
// GitHubOAuthEnabled is true when "github" is in OAuthProviders (backward compatibility).
GitHubOAuthEnabled bool `json:"github_oauth_enabled"`
}
AuthConfigResponse is the response for GET /api/auth/config (no auth).
type CreateOrganizationRequest ¶
type CreateOrganizationRequest struct {
Name string `json:"name"`
}
CreateOrganizationRequest is the body for POST /api/admin/organizations.
type CreateSignupInviteRequest ¶
type CreateSignupInviteRequest struct {
ExpiresInHours int `json:"expires_in_hours"`
OrganizationID uuid.UUID `json:"organization_id,omitempty"`
Role string `json:"role,omitempty"`
}
CreateSignupInviteRequest is the body for POST /api/admin/signup-invites.
type CreateSignupInviteResponse ¶
type CreateSignupInviteResponse struct {
InviteURL string `json:"invite_url"`
Token string `json:"token"`
ExpiresAt time.Time `json:"expires_at"`
}
CreateSignupInviteResponse is the response for POST /api/admin/signup-invites.
type CreateTokenRequest ¶
type CreateTokenRequest struct {
Name string `json:"name"`
ExpiresAt *string `json:"expires_at,omitempty"`
OrganizationID *string `json:"organization_id,omitempty"` // optional; global admin only — scopes token to this org
}
CreateTokenRequest is the body for POST /api/auth/me/tokens.
type CreateUserRequest ¶
type CreateUserRequest struct {
Email string `json:"email"`
Password string `json:"password"` // #nosec G117 -- request DTO for admin create user, not a log/secret leak
Role string `json:"role"`
OrganizationID uuid.UUID `json:"organization_id,omitempty"`
}
CreateUserRequest is the body for POST /api/admin/users.
type OrganizationResponse ¶
type OrganizationResponse struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt string `json:"created_at"`
}
OrganizationResponse is one organization in list or create response.
type RegisterWithInviteRequest ¶
type RegisterWithInviteRequest struct {
Token string `json:"token"`
Email string `json:"email"`
Password string `json:"password"` // #nosec G117 -- request DTO for signup, not a log/secret leak
}
RegisterWithInviteRequest is the body for POST /api/signup/register.
type SignupInviteResponse ¶
type SignupInviteResponse struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
UsedAt *time.Time `json:"used_at,omitempty"`
UsedByEmail string `json:"used_by_email,omitempty"`
}
SignupInviteResponse is one invite in the list for GET /api/admin/signup-invites.
type UpdateOrganizationRequest ¶
type UpdateOrganizationRequest struct {
Name string `json:"name"`
}
UpdateOrganizationRequest is the body for PATCH /api/admin/organizations/:id.
type UpdateUserOrganizationRequest ¶
UpdateUserOrganizationRequest is the body for PATCH /api/admin/users/:id/organization. Global admin only.
type UpdateUserRoleRequest ¶
type UpdateUserRoleRequest struct {
Role string `json:"role"`
}
UpdateUserRoleRequest is the body for PATCH /api/admin/users/:id/role.
type UserResponse ¶
type UserResponse struct {
ID string `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
TourCompleted bool `json:"tour_completed"`
OrganizationID string `json:"organization_id,omitempty"`
}
UserResponse is the user object returned by auth and admin endpoints.
type ValidateSignupInviteResponse ¶
type ValidateSignupInviteResponse struct {
Valid bool `json:"valid"`
ExpiresAt time.Time `json:"expires_at"`
}
ValidateSignupInviteResponse is the response for GET /api/signup/validate.