api

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 39 Imported by: 0

Documentation

Overview

Package api provides HTTP handlers for the OzyBase Core.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIKeyMiddleware added in v1.1.1

func APIKeyMiddleware(db *data.DB) echo.MiddlewareFunc

APIKeyMiddleware validates OzyBase API keys (Enterprise Phase 1)

func APIVersionHeader

func APIVersionHeader(version string) echo.MiddlewareFunc

APIVersionHeader adds API version header to responses

func AccessMiddleware

func AccessMiddleware(db *data.DB, requirement string) echo.MiddlewareFunc

AccessMiddleware checks per-collection permissions (ACL)

func AuthMiddleware

func AuthMiddleware(db *data.DB, jwtSecret string, optional bool) echo.MiddlewareFunc

func ConstantTimeCompare

func ConstantTimeCompare(a, b string) bool

ConstantTimeCompare performs a constant-time comparison of two strings This prevents timing attacks when comparing sensitive data like tokens

func GenerateRandomKey added in v1.1.1

func GenerateRandomKey() (string, error)

GenerateRandomKey creates a new random secure key

func IsCommonPassword

func IsCommonPassword(password string) bool

IsCommonPassword checks if the password is in a list of common passwords

func MetricsMiddleware added in v1.1.1

func MetricsMiddleware(h *Handler) echo.MiddlewareFunc

MetricsMiddleware tracks activity for the dashboard and persists audit logs

func PrometheusMiddleware added in v1.1.1

func PrometheusMiddleware() echo.MiddlewareFunc

PrometheusMiddleware is a placeholder for custom Prometheus request tracking (Enterprise Phase 1)

func RLSMiddleware added in v1.1.1

func RLSMiddleware(db *data.DB) echo.MiddlewareFunc

RLSMiddleware injects user context into Postgres for the duration of the request

func RegisterPrometheus added in v1.1.1

func RegisterPrometheus(e *echo.Echo)

RegisterPrometheus registers the metrics endpoint (Enterprise Phase 1)

func RegisterStaticRoutes

func RegisterStaticRoutes(e *echo.Echo)

RegisterStaticRoutes registers the routes for serving the embedded frontend

func RequireRole added in v1.1.1

func RequireRole(requiredRole string) echo.MiddlewareFunc

RequireRole enforces an exact role match for sensitive routes.

func SecurityHeadersDefault

func SecurityHeadersDefault() echo.MiddlewareFunc

SecurityHeadersDefault is a convenience function using default config

func SecurityHeadersMiddleware

func SecurityHeadersMiddleware(config SecurityConfig) echo.MiddlewareFunc

SecurityHeadersMiddleware adds security headers to all responses

func TimeoutMiddleware

func TimeoutMiddleware(timeout time.Duration) echo.MiddlewareFunc

TimeoutMiddleware adds a timeout to each request

func ValidateEmail

func ValidateEmail(email string) error

ValidateEmail validates email format using regex for more precise control

func ValidatePasswordComplexity

func ValidatePasswordComplexity(password string, policy PasswordPolicy) error

ValidatePasswordComplexity validates password against the policy

func ValidatePasswordSimple

func ValidatePasswordSimple(password string) error

ValidatePasswordSimple performs basic password validation (minimum length only) Use this for less strict environments, ValidatePasswordComplexity for production

func WorkspaceMiddleware added in v1.1.1

func WorkspaceMiddleware(db *data.DB, jwtSecret string) echo.MiddlewareFunc

WorkspaceMiddleware ensures the user has access to the requested workspace

Types

type APIKey added in v1.1.1

type APIKey struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Prefix      string     `json:"prefix"`
	Role        string     `json:"role"`
	IsActive    bool       `json:"is_active"`
	ExpiresAt   *time.Time `json:"expires_at"`
	CreatedAt   time.Time  `json:"created_at"`
	LastUsedAt  *time.Time `json:"last_used_at"`
	WorkspaceID string     `json:"workspace_id,omitempty"`
}

type AnalyticsHandler added in v1.1.1

type AnalyticsHandler struct {
	Handler *Handler
}

AnalyticsHandler handles high-performance analytics queries

type AuthHandler

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

func NewAuthHandler

func NewAuthHandler(authService AuthService) *AuthHandler

func (*AuthHandler) ConfirmReset added in v1.1.1

func (h *AuthHandler) ConfirmReset(c echo.Context) error

func (*AuthHandler) GetOAuthURL added in v1.1.1

func (h *AuthHandler) GetOAuthURL(c echo.Context) error

func (*AuthHandler) ListSessions added in v1.1.1

func (h *AuthHandler) ListSessions(c echo.Context) error

func (*AuthHandler) Login

func (h *AuthHandler) Login(c echo.Context) error

func (*AuthHandler) OAuthCallback added in v1.1.1

func (h *AuthHandler) OAuthCallback(c echo.Context) error

func (*AuthHandler) RequestReset added in v1.1.1

func (h *AuthHandler) RequestReset(c echo.Context) error

func (*AuthHandler) RevokeSession added in v1.1.1

func (h *AuthHandler) RevokeSession(c echo.Context) error

func (*AuthHandler) Signup

func (h *AuthHandler) Signup(c echo.Context) error

func (*AuthHandler) UpdateRole added in v1.1.1

func (h *AuthHandler) UpdateRole(c echo.Context) error

func (*AuthHandler) VerifyEmail added in v1.1.1

func (h *AuthHandler) VerifyEmail(c echo.Context) error

type AuthRequest

type AuthRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type AuthService added in v1.1.1

type AuthService interface {
	Signup(ctx context.Context, email, password string) (*core.User, error)
	Login(ctx context.Context, email, password string) (*core.AuthLoginResult, error)
	RequestPasswordReset(ctx context.Context, email string) (string, error)
	ConfirmPasswordReset(ctx context.Context, token, newPassword string) error
	VerifyEmail(ctx context.Context, token string) error
	UpdateUserRole(ctx context.Context, userID, newRole string) error
	HandleOAuthLogin(ctx context.Context, provider, providerID, email string, data map[string]any) (string, *core.User, error)
	ListSessions(ctx context.Context, userID string) ([]core.Session, error)
	RevokeSession(ctx context.Context, sessionID, userID string) error
}

type Collection

type Collection struct {
	ID              string             `json:"id"`
	Name            string             `json:"name"`
	IsSystem        bool               `json:"is_system"`
	Schema          []data.FieldSchema `json:"schema"`
	ListRule        string             `json:"list_rule"`
	CreateRule      string             `json:"create_rule"`
	RlsEnabled      bool               `json:"rls_enabled"`
	RlsRule         string             `json:"rls_rule"`
	RealtimeEnabled bool               `json:"realtime_enabled"`
	WorkspaceID     string             `json:"workspace_id,omitempty"`
	CreatedAt       time.Time          `json:"created_at"`
	UpdatedAt       time.Time          `json:"updated_at"`
}

Collection represents a collection in the system

type CreateCollectionRequest

type CreateCollectionRequest struct {
	Name            string             `json:"name"`
	Schema          []data.FieldSchema `json:"schema"`
	ListRule        string             `json:"list_rule"`   // "public", "auth", "admin"
	CreateRule      string             `json:"create_rule"` // "auth", "admin"
	RlsEnabled      bool               `json:"rls_enabled"`
	RlsRule         string             `json:"rls_rule"`
	RealtimeEnabled bool               `json:"realtime_enabled"`
	WorkspaceID     string             `json:"workspace_id"`
}

CreateCollectionRequest represents the request to create a new collection

type CronHandler added in v1.1.1

type CronHandler struct {
	DB   *data.DB
	Cron *realtime.CronManager
}

func NewCronHandler added in v1.1.1

func NewCronHandler(db *data.DB, cronMgr *realtime.CronManager) *CronHandler

func (*CronHandler) Create added in v1.1.1

func (h *CronHandler) Create(c echo.Context) error

func (*CronHandler) Delete added in v1.1.1

func (h *CronHandler) Delete(c echo.Context) error

func (*CronHandler) List added in v1.1.1

func (h *CronHandler) List(c echo.Context) error

type CronJobInfo added in v1.1.1

type CronJobInfo struct {
	ID       string  `json:"id"`
	Name     string  `json:"name"`
	Schedule string  `json:"schedule"`
	Command  string  `json:"command"`
	IsActive bool    `json:"is_active"`
	LastRun  *string `json:"last_run,omitempty"`
}

type DbMetrics added in v1.1.1

type DbMetrics struct {
	DbRequests       int       `json:"db_requests"`
	AuthRequests     int       `json:"auth_requests"`
	StorageRequests  int       `json:"storage_requests"`
	RealtimeRequests int       `json:"realtime_requests"`
	DbHistory        []int     `json:"db_history"`
	AuthHistory      []int     `json:"auth_history"`
	StorageHistory   []int     `json:"storage_history"`
	RealtimeHistory  []int     `json:"realtime_history"`
	CpuHistory       []float64 `json:"cpu_history"`
	RamHistory       []float64 `json:"ram_history"`
}

type ExtensionInfo added in v1.1.1

type ExtensionInfo struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Installed   bool   `json:"installed"`
	Description string `json:"description"`
}

type FileHandler

type FileHandler struct {
	DB         *data.DB
	StorageDir string
}

FileHandler handles file uploads and storage policies

func NewFileHandler

func NewFileHandler(db *data.DB, storageDir string) *FileHandler

NewFileHandler creates a new instance of FileHandler

func (*FileHandler) CreateBucket added in v1.1.1

func (h *FileHandler) CreateBucket(c echo.Context) error

CreateBucket handles POST /api/files/buckets

func (*FileHandler) List added in v1.1.1

func (h *FileHandler) List(c echo.Context) error

List handles GET /api/files

func (*FileHandler) ListBuckets added in v1.1.1

func (h *FileHandler) ListBuckets(c echo.Context) error

ListBuckets handles GET /api/files/buckets

func (*FileHandler) Upload

func (h *FileHandler) Upload(c echo.Context) error

Upload handles POST /api/files

type FixHealthRequest added in v1.1.1

type FixHealthRequest struct {
	Type  string `json:"type"`
	Issue string `json:"issue"`
}

FixHealthRequest represents a request to fix a health issue

type FunctionInfo added in v1.1.1

type FunctionInfo struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Status  string `json:"status"`
	Method  string `json:"method"`
	URL     string `json:"url"`
	LastRun string `json:"lastRun"`
	Script  string `json:"script,omitempty"`
}

type FunctionsHandler added in v1.1.1

type FunctionsHandler struct {
	DB           *data.DB
	FunctionsDir string
}

func NewFunctionsHandler added in v1.1.1

func NewFunctionsHandler(db *data.DB, dir string) *FunctionsHandler

func (*FunctionsHandler) Create added in v1.1.1

func (h *FunctionsHandler) Create(c echo.Context) error

func (*FunctionsHandler) Invoke added in v1.1.1

func (h *FunctionsHandler) Invoke(c echo.Context) error

func (*FunctionsHandler) List added in v1.1.1

func (h *FunctionsHandler) List(c echo.Context) error

func (*FunctionsHandler) ListExtensions added in v1.1.1

func (h *FunctionsHandler) ListExtensions(c echo.Context) error

type GeoStat added in v1.1.1

type GeoStat struct {
	Country string `json:"country"`
	Count   int64  `json:"count"`
}

type Handler

type Handler struct {
	DB           *data.DB
	Metrics      *Metrics
	Broker       *realtime.Broker
	Webhooks     *realtime.WebhookDispatcher
	Geo          *core.GeoService
	Mailer       mailer.Mailer
	Integrations *realtime.WebhookIntegration
	Auth         *core.AuthService
	Audit        *core.AuditService
	Storage      storage.Provider
	PubSub       realtime.PubSub
	Migrations   *migrations.Generator
	Applier      *migrations.Applier
	StartTime    time.Time
}

Handler holds dependencies for HTTP handlers

func NewHandler

func NewHandler(db *data.DB, broker *realtime.Broker, webhooks *realtime.WebhookDispatcher, mailSvc mailer.Mailer, storageSvc storage.Provider, ps realtime.PubSub, migrator *migrations.Generator, applier *migrations.Applier, audit *core.AuditService) *Handler

NewHandler creates a new Handler with the given dependencies

func (*Handler) AddColumn added in v1.1.1

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

AddColumn handles POST /api/tables/:name/columns

func (*Handler) AddNotificationRecipient added in v1.1.1

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

AddNotificationRecipient handles POST /api/project/security/notifications

func (*Handler) CreateAPIKey added in v1.1.1

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

func (*Handler) CreateCollection

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

CreateCollection handles POST /api/collections

func (*Handler) CreateIPRule added in v1.1.1

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

func (*Handler) CreateIntegration added in v1.1.1

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

CreateIntegration handles POST /api/project/integrations

func (*Handler) CreateRecord

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

CreateRecord handles POST /api/collections/:name/records

func (*Handler) CreateSecret added in v1.1.1

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

func (*Handler) CreateWrapper added in v1.1.1

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

func (*Handler) DeleteAPIKey added in v1.1.1

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

func (*Handler) DeleteCollection added in v1.1.1

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

DeleteCollection handles DELETE /api/collections/:name

func (*Handler) DeleteColumn added in v1.1.1

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

DeleteColumn handles DELETE /api/tables/:name/columns/:col

func (*Handler) DeleteIPRule added in v1.1.1

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

func (*Handler) DeleteIntegration added in v1.1.1

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

DeleteIntegration handles DELETE /api/project/integrations/:id

func (*Handler) DeleteNotificationRecipient added in v1.1.1

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

DeleteNotificationRecipient handles DELETE /api/project/security/notifications/:id

func (*Handler) DeleteRecord added in v1.1.1

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

DeleteRecord handles DELETE /api/collections/:name/records/:id

func (*Handler) DeleteSecret added in v1.1.1

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

func (*Handler) DeleteWrapper added in v1.1.1

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

func (*Handler) ExportLogs added in v1.1.1

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

ExportLogs handles GET /api/project/logs/export

func (*Handler) FirewallMiddleware added in v1.1.1

func (h *Handler) FirewallMiddleware() echo.MiddlewareFunc

FirewallMiddleware checks every request against the IP blacklist/whitelist

func (*Handler) FixHealthIssues added in v1.1.1

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

FixHealthIssues handles POST /api/project/health/fix

func (*Handler) GetGeoStats added in v1.1.1

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

GetGeoStats returns traffic distribution by country

func (*Handler) GetHealthIssues added in v1.1.1

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

GetHealthIssues handles GET /api/project/health

func (*Handler) GetLogs added in v1.1.1

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

GetLogs handles GET /api/project/logs Supports ?source=memory for real-time live tail (in-memory buffer) Defaults to database source for historical explorer view

func (*Handler) GetNotificationRecipients added in v1.1.1

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

GetNotificationRecipients handles GET /api/project/security/notifications

func (*Handler) GetProjectInfo added in v1.1.1

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

GetProjectInfo handles GET /api/project/info

func (*Handler) GetPrometheusMetrics added in v1.1.1

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

GetPrometheusMetrics returns Go runtime statistics in Prometheus format

func (*Handler) GetRecord

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

GetRecord handles GET /api/collections/:name/records/:id

func (*Handler) GetSecurityAlerts added in v1.1.1

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

GetSecurityAlerts handles GET /api/project/security/alerts

func (*Handler) GetSecurityPolicies added in v1.1.1

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

GetSecurityPolicies handles GET /api/project/security/policies

func (*Handler) GetSecurityStats added in v1.1.1

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

GetSecurityStats handles GET /api/project/security/stats

func (*Handler) GetStats added in v1.1.1

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

GetStats handles GET /api/project/stats

func (*Handler) GetSystemStatus added in v1.1.1

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

GetSystemStatus checks if the system is initialized (has an admin user)

func (*Handler) GetTableSchema

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

GetTableSchema handles GET /api/schema/:name

func (*Handler) GetTrafficStats added in v1.1.1

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

GetTrafficStats returns aggregated traffic data (requests per minute/hour) This leverages PostgreSQL's speed instead of JS client-side processing

func (*Handler) GetVisualizeSchema added in v1.1.1

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

GetVisualizeSchema handles GET /api/collections/visualize

func (*Handler) HandleExecuteSQL added in v1.1.1

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

HandleExecuteSQL executes a raw SQL query provided by the admin

func (*Handler) HandleGraphQL added in v1.1.1

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

GRAPHQL HANDLER

func (*Handler) HandleSyncSystem added in v1.1.1

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

HandleSyncSystem triggers the internal migrations to repair system schema

func (*Handler) Health

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

Health handles GET /api/health

func (*Handler) ImportRecords added in v1.1.1

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

ImportRecords handles POST /api/tables/:name/import

func (*Handler) ListAPIKeys added in v1.1.1

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

func (*Handler) ListCollections

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

ListCollections handles GET /api/collections

func (*Handler) ListExtensions added in v1.1.1

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

I will move this to handlers.go or a new extensions.go that uses Handler struct

func (*Handler) ListIPRules added in v1.1.1

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

func (*Handler) ListIntegrations added in v1.1.1

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

ListIntegrations handles GET /api/project/integrations

func (*Handler) ListRecords

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

ListRecords handles GET /api/collections/:name/records

func (*Handler) ListSchemas added in v1.1.1

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

ListSchemas handles GET /api/schemas

func (*Handler) ListSecrets added in v1.1.1

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

VAULT HANDLERS

func (*Handler) ListWrappers added in v1.1.1

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

WRAPPERS HANDLERS

func (*Handler) SetupSystem added in v1.1.1

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

SetupSystem handles the initial setup (First Time Run)

func (*Handler) StartLogCleaner added in v1.1.1

func (h *Handler) StartLogCleaner(ctx context.Context)

StartLogCleaner removes logs older than 30 days every 24 hours

func (*Handler) StartLogExporter added in v1.1.1

func (h *Handler) StartLogExporter(ctx context.Context)

StartLogExporter starts a background worker to flush logs to SIEM

func (*Handler) TestIntegration added in v1.1.1

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

TestIntegration handles POST /api/project/integrations/:id/test

func (*Handler) ToggleAPIKey added in v1.1.1

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

func (*Handler) ToggleExtension added in v1.1.1

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

func (*Handler) UpdateCollectionRules added in v1.1.1

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

UpdateCollectionRules handles PATCH /api/collections/rules

func (*Handler) UpdateRealtimeToggle added in v1.1.1

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

UpdateRealtimeToggle handles PATCH /api/collections/realtime

func (*Handler) UpdateRecord added in v1.1.1

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

UpdateRecord handles PATCH /api/collections/:name/records/:id

func (*Handler) UpdateSecurityPolicy added in v1.1.1

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

UpdateSecurityPolicy handles POST /api/project/security/policies

type HealthIssue added in v1.1.1

type HealthIssue struct {
	Type        string `json:"type"` // "security" | "performance"
	Title       string `json:"title"`
	Description string `json:"description"`
}

HealthIssue represents a security or performance recommendation

type HealthResponse

type HealthResponse struct {
	Status    string `json:"status"`
	Database  string `json:"database"`
	Timestamp string `json:"timestamp"`
	Uptime    string `json:"uptime"`
	Memory    struct {
		Alloc      uint64 `json:"alloc_mb"`
		TotalAlloc uint64 `json:"total_alloc_mb"`
		Sys        uint64 `json:"sys_mb"`
		NumGC      uint32 `json:"num_gc"`
	} `json:"memory"`
}

HealthResponse represents the health check response

type IPRule added in v1.1.1

type IPRule struct {
	ID        string     `json:"id"`
	IPAddress string     `json:"ip_address"`
	RuleType  string     `json:"rule_type"`
	Reason    string     `json:"reason"`
	ExpiresAt *time.Time `json:"expires_at"`
	CreatedAt time.Time  `json:"created_at"`
}

type IPStat added in v1.1.1

type IPStat struct {
	IP    string `json:"ip"`
	Count int64  `json:"count"`
}

type LogEntry added in v1.1.1

type LogEntry struct {
	ID        string    `json:"id"`
	Time      string    `json:"time"`
	Method    string    `json:"method"`
	Path      string    `json:"path"`
	Status    int       `json:"status"`
	Latency   string    `json:"latency"`
	IP        string    `json:"ip"`
	Country   string    `json:"country,omitempty"`
	City      string    `json:"city,omitempty"`
	Timestamp time.Time `json:"timestamp"` // Exposed for frontend comparisons
}

LogEntry represents a single request log

type Metrics added in v1.1.1

type Metrics struct {
	sync.RWMutex
	DbRequests      int
	AuthRequests    int
	StorageRequests int
	DbHistory       []int
	AuthHistory     []int
	StorageHistory  []int
	RealtimeHistory []int
	CpuHistory      []float64
	RamHistory      []float64
}

Metrics holds in-memory activity stats

type PasswordPolicy

type PasswordPolicy struct {
	MinLength        int
	RequireUppercase bool
	RequireLowercase bool
	RequireNumber    bool
	RequireSpecial   bool
}

PasswordPolicy defines the requirements for a valid password

func DefaultPasswordPolicy

func DefaultPasswordPolicy() PasswordPolicy

DefaultPasswordPolicy returns the default password requirements

type ProjectInfo added in v1.1.1

type ProjectInfo struct {
	Name             string      `json:"name"`
	Host             string      `json:"host"`
	Port             string      `json:"port"`
	Database         string      `json:"database"`
	User             string      `json:"user"`
	TableCount       int         `json:"table_count"`
	UserTableCount   int         `json:"user_table_count"`
	SystemTableCount int         `json:"system_table_count"`
	FunctionCount    int         `json:"function_count"`
	SchemaCount      int         `json:"schema_count"`
	DbSize           string      `json:"db_size"`
	Version          string      `json:"version"`
	Metrics          DbMetrics   `json:"metrics"`
	SlowQueries      []SlowQuery `json:"slow_queries"`
}

ProjectInfo represents the project information response

type RealtimeHandler

type RealtimeHandler struct {
	Broker *realtime.Broker
}

RealtimeHandler handles the SSE connection

func NewRealtimeHandler

func NewRealtimeHandler(broker *realtime.Broker) *RealtimeHandler

NewRealtimeHandler creates a new instances of RealtimeHandler

func (*RealtimeHandler) Stream

func (h *RealtimeHandler) Stream(c echo.Context) error

Stream handles GET /api/realtime

type SQLExecuteRequest added in v1.1.1

type SQLExecuteRequest struct {
	Query string `json:"query"`
}

type SQLExecuteResponse added in v1.1.1

type SQLExecuteResponse struct {
	Columns       []string        `json:"columns"`
	Rows          [][]interface{} `json:"rows"`
	RowCount      int             `json:"rowCount"`
	ExecutionTime string          `json:"executionTime"`
}

type SQLSyncResponse added in v1.1.1

type SQLSyncResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

type Secret added in v1.1.1

type Secret struct {
	ID          string    `json:"id"`
	Key         string    `json:"key"`
	Value       string    `json:"value"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
}

type SecurityConfig

type SecurityConfig struct {
	// ContentSecurityPolicy - Controls resources the browser is allowed to load
	ContentSecurityPolicy string
	// XFrameOptions - Prevents clickjacking attacks
	XFrameOptions string
	// XContentTypeOptions - Prevents MIME type sniffing
	XContentTypeOptions string
	// XSSProtection - XSS filter in browsers
	XSSProtection string
	// HSTSMaxAge - HTTP Strict Transport Security max age in seconds
	HSTSMaxAge int
	// HSTSIncludeSubdomains - Include subdomains in HSTS
	HSTSIncludeSubdomains bool
	// ReferrerPolicy - Controls how much referrer info is sent
	ReferrerPolicy string
	// PermissionsPolicy - Controls browser features
	PermissionsPolicy string
}

SecurityConfig holds configuration for security middleware

func DefaultSecurityConfig

func DefaultSecurityConfig() SecurityConfig

DefaultSecurityConfig returns production-ready security headers configuration

type SecurityStats added in v1.1.1

type SecurityStats struct {
	TotalChecks     int64           `json:"total_checks"`
	AllowedRequests int64           `json:"allowed_requests"`
	BlockedRequests int64           `json:"blocked_requests"`
	TopCountries    []GeoStat       `json:"top_countries"`
	TopIPs          []IPStat        `json:"top_ips"`
	AlertsTimeline  []TimelineEvent `json:"alerts_timeline"`
	TotalBreaches   int64           `json:"total_breaches"`
	LastBreachAt    string          `json:"last_breach_at"`
}

SecurityStats represents data for the security dashboard

type SlowQuery added in v1.1.1

type SlowQuery struct {
	Query   string  `json:"query"`
	AvgTime float64 `json:"avg_time"` // in seconds
	Calls   int     `json:"calls"`
}

type TimelineEvent added in v1.1.1

type TimelineEvent struct {
	Time  string `json:"time"`
	Count int64  `json:"count"`
}

type TwoFactorHandler added in v1.1.1

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

func NewTwoFactorHandler added in v1.1.1

func NewTwoFactorHandler(service *core.TwoFactorService, authService *core.AuthService) *TwoFactorHandler

func (*TwoFactorHandler) Disable2FA added in v1.1.1

func (h *TwoFactorHandler) Disable2FA(c echo.Context) error

Disable2FA disables 2FA for the user

func (*TwoFactorHandler) Enable2FA added in v1.1.1

func (h *TwoFactorHandler) Enable2FA(c echo.Context) error

Enable2FA enables 2FA after verifying the code

func (*TwoFactorHandler) Get2FAStatus added in v1.1.1

func (h *TwoFactorHandler) Get2FAStatus(c echo.Context) error

Get2FAStatus returns whether 2FA is enabled for the user

func (*TwoFactorHandler) Setup2FA added in v1.1.1

func (h *TwoFactorHandler) Setup2FA(c echo.Context) error

Setup2FA generates a new 2FA secret and QR code

func (*TwoFactorHandler) Verify2FA added in v1.1.1

func (h *TwoFactorHandler) Verify2FA(c echo.Context) error

Verify2FA verifies a 2FA code during login

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

ValidationError represents a validation failure with details

func (ValidationError) Error

func (e ValidationError) Error() string

type WebhookHandler added in v1.1.1

type WebhookHandler struct {
	DB *data.DB
}

func NewWebhookHandler added in v1.1.1

func NewWebhookHandler(db *data.DB) *WebhookHandler

func (*WebhookHandler) Create added in v1.1.1

func (h *WebhookHandler) Create(c echo.Context) error

func (*WebhookHandler) Delete added in v1.1.1

func (h *WebhookHandler) Delete(c echo.Context) error

func (*WebhookHandler) List added in v1.1.1

func (h *WebhookHandler) List(c echo.Context) error

type WebhookInfo added in v1.1.1

type WebhookInfo struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	URL      string `json:"url"`
	Events   string `json:"events"`
	Secret   string `json:"secret,omitempty"`
	IsActive bool   `json:"is_active"`
}

type WorkspaceHandler added in v1.1.1

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

func NewWorkspaceHandler added in v1.1.1

func NewWorkspaceHandler(service *core.WorkspaceService, mailer mailer.Mailer) *WorkspaceHandler

func (*WorkspaceHandler) AddMember added in v1.1.1

func (h *WorkspaceHandler) AddMember(c echo.Context) error

func (*WorkspaceHandler) Create added in v1.1.1

func (h *WorkspaceHandler) Create(c echo.Context) error

func (*WorkspaceHandler) Delete added in v1.1.1

func (h *WorkspaceHandler) Delete(c echo.Context) error

func (*WorkspaceHandler) List added in v1.1.1

func (h *WorkspaceHandler) List(c echo.Context) error

func (*WorkspaceHandler) ListMembers added in v1.1.1

func (h *WorkspaceHandler) ListMembers(c echo.Context) error

func (*WorkspaceHandler) RemoveMember added in v1.1.1

func (h *WorkspaceHandler) RemoveMember(c echo.Context) error

func (*WorkspaceHandler) Update added in v1.1.1

func (h *WorkspaceHandler) Update(c echo.Context) error

type Wrapper added in v1.1.1

type Wrapper struct {
	Name    string `json:"name"`
	Handler string `json:"handler"`
	Status  string `json:"status"`
}

Jump to

Keyboard shortcuts

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