Documentation
¶
Index ¶
- func RequestIDFromCtx(ctx context.Context) (string, bool)
- func RequestLogger(l *logrus.Logger, debugPaths ...string) func(http.Handler) http.Handler
- func SecurityHeaders() func(http.Handler) http.Handler
- func UserIDFromCtx(ctx context.Context) (string, bool)
- func WithUserID(ctx context.Context, uid string) context.Context
- type Config
- type MonitoringConfig
- type OAuthAuthorizationServerMetadata
- type PublicCat
- type PublicRecord
- type Server
- func (s *Server) AuditMiddleware(next http.Handler) http.Handler
- func (s *Server) BotKeyAuth(next http.Handler) http.Handler
- func (s *Server) CSRFProtection(next http.Handler) http.Handler
- func (s *Server) DevEnabled() bool
- func (s *Server) GoogleEnabled() bool
- func (s *Server) JWTAuth(next http.Handler) http.Handler
- func (s *Server) LogAudit(r *http.Request, targetType, targetID, status, delta string)
- func (s *Server) OIDCEnabled() bool
- func (s *Server) RequireAuth(next http.Handler) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequestLogger ¶
RequestLogger logs basic request info.
func SecurityHeaders ¶
SecurityHeaders adds common security-related headers to all responses.
Types ¶
type Config ¶
type Config struct {
Store *storage.Store
Logger *logrus.Logger
Version string
CORSAllowOrigin []string
Monitoring MonitoringConfig
JWTSecret string
AccessTTL time.Duration
RefreshTTL time.Duration
AuditLogTTL time.Duration
OAuth oauth.Config
BotAPIKey string
SessionStore sessions.SessionStore
DevLoginEnabled bool
SkipWorkers bool
}
type MonitoringConfig ¶
type OAuthAuthorizationServerMetadata ¶ added in v0.0.3
type OAuthAuthorizationServerMetadata struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint,omitempty"`
TokenEndpoint string `json:"token_endpoint,omitempty"`
RegistrationEndpoint string `json:"registration_endpoint,omitempty"`
UserinfoEndpoint string `json:"userinfo_endpoint,omitempty"`
ScopesSupported []string `json:"scopes_supported,omitempty"`
ResponseTypesSupported []string `json:"response_types_supported,omitempty"`
GrantTypesSupported []string `json:"grant_types_supported,omitempty"`
// Custom CatWatch metadata to replace /api/config
Config struct {
GoogleEnabled bool `json:"google_enabled"`
OIDCEnabled bool `json:"oidc_enabled"`
DevLogin bool `json:"dev_login"`
} `json:"x_catwatch_config"`
}
OAuthAuthorizationServerMetadata represents OAuth 2.0 Authorization Server Metadata (RFC 8414).
type PublicCat ¶
type PublicCat struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Color string `json:"color,omitempty"`
BirthDate *time.Time `json:"birth_date,omitempty"`
Gender string `json:"gender"`
IsSterilized bool `json:"is_sterilized"`
Condition int `json:"condition"`
NeedAttention bool `json:"need_attention"`
Tags []storage.Tag `json:"tags,omitempty"`
LastSeen *time.Time `json:"last_seen,omitempty"`
Locations []storage.CatLocation `json:"locations,omitempty"`
Images []storage.Image `json:"images,omitempty"`
Likes int64 `json:"likes"`
Liked bool `json:"liked"`
CreatedAt time.Time `json:"created_at"`
Records any `json:"records,omitempty"`
}
func ToPublicCat ¶
type PublicRecord ¶
type PublicRecord struct {
ID string `json:"id"`
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
DoneAt *time.Time `json:"done_at,omitempty"`
}
func ToPublicRecord ¶
func ToPublicRecord(r storage.Record) PublicRecord
type Server ¶
func (*Server) AuditMiddleware ¶
AuditMiddleware logs mutations to the AuditLog table.
func (*Server) BotKeyAuth ¶ added in v0.0.8
BotKeyAuth requires a valid X-Bot-Key header on every request. If BotAPIKey is not configured the endpoint is closed to all callers.
func (*Server) CSRFProtection ¶ added in v0.0.3
CSRFProtection implements a simple CSRF check for state-changing requests.
func (*Server) DevEnabled ¶ added in v0.0.6
func (*Server) GoogleEnabled ¶ added in v0.0.6
func (*Server) OIDCEnabled ¶ added in v0.0.6
Click to show internal directories.
Click to hide internal directories.