Documentation
¶
Overview ¶
Package rest provides a RESTful HTTP API for the LDAP server.
The REST API allows modern applications to interact with the LDAP directory using standard HTTP methods and JSON payloads. All REST operations are translated to LDAP operations via the backend interface.
Endpoints ¶
Authentication:
POST /api/v1/auth/bind - Authenticate and get JWT token
Entries:
GET /api/v1/entries/{dn} - Get single entry
POST /api/v1/entries - Create new entry
PUT /api/v1/entries/{dn} - Update entry (full replace)
PATCH /api/v1/entries/{dn} - Update entry (partial)
DELETE /api/v1/entries/{dn} - Delete entry
POST /api/v1/entries/{dn}/move - Rename/move entry
Search:
GET /api/v1/search - Search with pagination GET /api/v1/search/stream - Streaming search (NDJSON)
Other:
POST /api/v1/bulk - Bulk operations POST /api/v1/compare - Compare attribute value GET /api/v1/health - Health check
Authentication ¶
The API supports two authentication methods:
- JWT Bearer token: Obtained via /api/v1/auth/bind
- Basic Auth: Standard HTTP Basic Authentication
Example Usage ¶
// Get JWT token
curl -X POST http://localhost:8080/api/v1/auth/bind \
-H "Content-Type: application/json" \
-d '{"dn": "cn=admin,dc=example,dc=com", "password": "secret"}'
// Search with token
curl -X GET "http://localhost:8080/api/v1/search?baseDN=dc=example,dc=com&scope=sub" \
-H "Authorization: Bearer <token>"
Index ¶
- Variables
- func BindDN(r *http.Request) string
- func Param(r *http.Request, name string) string
- type ACLConfigJSON
- type ACLRuleJSON
- type ACLStatsJSON
- type ActivityEntry
- type AddRequest
- type Authenticator
- type BindRequest
- type BindResponse
- type BulkOperation
- type BulkOperationResult
- type BulkRequest
- type BulkResponse
- type CompareRequest
- type CompareResponse
- type Entry
- type ErrorResponse
- type Handlers
- func (h *Handlers) DecrementConnections()
- func (h *Handlers) HandleActivities(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleAddACLRule(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleAddEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleArchiveLogsNow(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleBind(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleBulk(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleCleanupArchives(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleClearLogs(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleClusterHealth(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleClusterLeader(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleClusterStatus(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleCompare(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleDeleteACLRule(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleDeleteEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleDisableEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleEnableEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleExportLogs(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetACL(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetACLRule(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetACLRules(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetConfig(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetConfigSection(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetLockStatus(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetLogArchiveStats(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetLogArchives(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetLogStats(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetLogs(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleGetPublicConfig(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleHealth(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleInternalLog(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleModifyDN(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleModifyEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleReloadACL(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleReloadConfig(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleSaveACL(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleSaveConfig(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleSearch(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleSetDefaultPolicy(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleStats(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleStreamSearch(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleUnlockEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleUpdateACLRule(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleUpdateConfigSection(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleValidateACL(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) HandleValidateConfig(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) IncrementConnections()
- func (h *Handlers) SetACLManager(m *acl.Manager)
- func (h *Handlers) SetClusterBackend(cb *raft.ClusterBackend)
- func (h *Handlers) SetConfigManager(m *config.ConfigManager)
- func (h *Handlers) SetLogger(logger logging.Logger)
- type HealthResponse
- type InternalLogRequest
- type JWTClaims
- type LogQueryRequest
- type LogQueryResponse
- type LogStatsResponse
- type Middleware
- func AdminOnlyMiddleware(adminDNs []string, adminPaths []string, excludePaths []string) Middleware
- func AuthMiddleware(auth *Authenticator, excludePaths []string) Middleware
- func CORSMiddleware(allowedOrigins []string) Middleware
- func ConnectionTrackingMiddleware(handlers *Handlers) Middleware
- func LoggingMiddleware(logger logging.Logger) Middleware
- func RateLimitMiddleware(requestsPerSecond int) Middleware
- func RecoveryMiddleware(logger logging.Logger) Middleware
- type ModifyChange
- type ModifyDNRequest
- type ModifyRequest
- type OperationStats
- type Route
- type Router
- func (r *Router) DELETE(pattern string, handler http.HandlerFunc)
- func (r *Router) GET(pattern string, handler http.HandlerFunc)
- func (r *Router) Handle(method, pattern string, handler http.HandlerFunc)
- func (r *Router) OPTIONS(pattern string, handler http.HandlerFunc)
- func (r *Router) PATCH(pattern string, handler http.HandlerFunc)
- func (r *Router) POST(pattern string, handler http.HandlerFunc)
- func (r *Router) PUT(pattern string, handler http.HandlerFunc)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(mw Middleware)
- type SearchRequest
- type SearchResponse
- type SecurityStats
- type Server
- func (s *Server) GetCORSOrigins() []string
- func (s *Server) GetRateLimit() int
- func (s *Server) GetTokenTTL() time.Duration
- func (s *Server) SetACLManager(m *acl.Manager)
- func (s *Server) SetCORSOrigins(origins []string)
- func (s *Server) SetClusterBackend(cb *raft.ClusterBackend)
- func (s *Server) SetConfigManager(m *config.ConfigManager)
- func (s *Server) SetLogger(logger logging.Logger)
- func (s *Server) SetRateLimit(requestsPerSecond int)
- func (s *Server) SetTokenTTL(ttl time.Duration)
- func (s *Server) Start() error
- func (s *Server) Stop(ctx context.Context) error
- type ServerConfig
- type StatsResponse
- type StorageStats
- type SystemStats
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidToken = errors.New("rest: invalid token") ErrTokenExpired = errors.New("rest: token expired") )
Auth errors.
Functions ¶
Types ¶
type ACLConfigJSON ¶
type ACLConfigJSON struct {
DefaultPolicy string `json:"defaultPolicy"`
Rules []ACLRuleJSON `json:"rules"`
Stats *ACLStatsJSON `json:"stats,omitempty"`
}
ACLConfigJSON represents ACL configuration in JSON format.
type ACLRuleJSON ¶
type ACLRuleJSON struct {
Target string `json:"target"`
Subject string `json:"subject"`
Scope string `json:"scope"`
Rights []string `json:"rights"`
Attributes []string `json:"attributes,omitempty"`
Deny bool `json:"deny"`
}
ACLRuleJSON represents an ACL rule in JSON format.
type ACLStatsJSON ¶
type ACLStatsJSON struct {
RuleCount int `json:"ruleCount"`
LastReload time.Time `json:"lastReload"`
ReloadCount uint64 `json:"reloadCount"`
FilePath string `json:"filePath,omitempty"`
}
ACLStatsJSON represents ACL statistics.
type ActivityEntry ¶ added in v1.0.2
type ActivityEntry struct {
Timestamp time.Time `json:"timestamp"`
Type string `json:"type"`
User string `json:"user,omitempty"`
Target string `json:"target,omitempty"`
Message string `json:"message"`
Source string `json:"source,omitempty"`
}
ActivityEntry represents a recent activity log entry.
type AddRequest ¶
AddRequest represents an add request.
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator handles authentication.
func NewAuthenticator ¶
func NewAuthenticator(be *backend.ObaBackend, jwtSecret string, tokenTTL time.Duration) *Authenticator
NewAuthenticator creates a new authenticator.
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate(dn, password string) (string, error)
Authenticate validates credentials and returns a JWT token.
func (*Authenticator) GetTokenTTL ¶
func (a *Authenticator) GetTokenTTL() time.Duration
GetTokenTTL returns the current token TTL.
func (*Authenticator) SetTokenTTL ¶
func (a *Authenticator) SetTokenTTL(ttl time.Duration)
SetTokenTTL updates the token TTL at runtime.
func (*Authenticator) ValidateToken ¶
func (a *Authenticator) ValidateToken(token string) (*JWTClaims, error)
ValidateToken validates a JWT token and returns the claims.
type BindRequest ¶
BindRequest represents an authentication request.
type BindResponse ¶
type BindResponse struct {
Success bool `json:"success"`
Token string `json:"token,omitempty"`
Message string `json:"message,omitempty"`
}
BindResponse represents an authentication response.
type BulkOperation ¶
type BulkOperation struct {
Operation string `json:"operation"`
DN string `json:"dn"`
Attributes map[string][]string `json:"attributes,omitempty"`
Changes []ModifyChange `json:"changes,omitempty"`
}
BulkOperation represents a single operation in a bulk request.
type BulkOperationResult ¶
type BulkOperationResult struct {
Index int `json:"index"`
DN string `json:"dn"`
Operation string `json:"operation"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
ResultCode int `json:"resultCode,omitempty"`
}
BulkOperationResult represents the result of a single bulk operation.
type BulkRequest ¶
type BulkRequest struct {
Operations []BulkOperation `json:"operations"`
StopOnError bool `json:"stopOnError"`
}
BulkRequest represents a bulk operation request.
type BulkResponse ¶
type BulkResponse struct {
Success bool `json:"success"`
TotalCount int `json:"totalCount"`
Succeeded int `json:"succeeded"`
Failed int `json:"failed"`
Results []BulkOperationResult `json:"results"`
}
BulkResponse represents a bulk operation response.
type CompareRequest ¶
type CompareRequest struct {
DN string `json:"dn"`
Attribute string `json:"attribute"`
Value string `json:"value"`
}
CompareRequest represents a compare request.
type CompareResponse ¶
type CompareResponse struct {
Match bool `json:"match"`
}
CompareResponse represents a compare response.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
Code int `json:"code"`
Message string `json:"message"`
ResultCode int `json:"resultCode,omitempty"`
}
ErrorResponse represents an error response.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers contains all REST API handlers.
func NewHandlers ¶
func NewHandlers(be *backend.ObaBackend, auth *Authenticator) *Handlers
NewHandlers creates new handlers.
func (*Handlers) DecrementConnections ¶
func (h *Handlers) DecrementConnections()
DecrementConnections decrements active connection count.
func (*Handlers) HandleActivities ¶ added in v1.0.2
func (h *Handlers) HandleActivities(w http.ResponseWriter, r *http.Request)
HandleActivities handles GET /api/v1/activities
func (*Handlers) HandleAddACLRule ¶
func (h *Handlers) HandleAddACLRule(w http.ResponseWriter, r *http.Request)
HandleAddACLRule handles POST /api/v1/acl/rules
func (*Handlers) HandleAddEntry ¶
func (h *Handlers) HandleAddEntry(w http.ResponseWriter, r *http.Request)
HandleAddEntry handles POST /api/v1/entries
func (*Handlers) HandleArchiveLogsNow ¶ added in v1.1.0
func (h *Handlers) HandleArchiveLogsNow(w http.ResponseWriter, r *http.Request)
HandleArchiveLogsNow handles POST /api/v1/logs/archive
func (*Handlers) HandleBind ¶
func (h *Handlers) HandleBind(w http.ResponseWriter, r *http.Request)
HandleBind handles POST /api/v1/auth/bind
func (*Handlers) HandleBulk ¶
func (h *Handlers) HandleBulk(w http.ResponseWriter, r *http.Request)
HandleBulk handles POST /api/v1/bulk
func (*Handlers) HandleCleanupArchives ¶ added in v1.1.0
func (h *Handlers) HandleCleanupArchives(w http.ResponseWriter, r *http.Request)
HandleCleanupArchives handles POST /api/v1/logs/archives/cleanup
func (*Handlers) HandleClearLogs ¶
func (h *Handlers) HandleClearLogs(w http.ResponseWriter, r *http.Request)
HandleClearLogs handles DELETE /api/v1/logs
func (*Handlers) HandleClusterHealth ¶ added in v1.1.0
func (h *Handlers) HandleClusterHealth(w http.ResponseWriter, r *http.Request)
HandleClusterHealth handles GET /api/v1/cluster/health Returns 200 if leader, 503 if not leader (for HAProxy routing)
func (*Handlers) HandleClusterLeader ¶ added in v1.1.0
func (h *Handlers) HandleClusterLeader(w http.ResponseWriter, r *http.Request)
HandleClusterLeader handles GET /api/v1/cluster/leader
func (*Handlers) HandleClusterStatus ¶ added in v1.1.0
func (h *Handlers) HandleClusterStatus(w http.ResponseWriter, r *http.Request)
HandleClusterStatus handles GET /api/v1/cluster/status
func (*Handlers) HandleCompare ¶
func (h *Handlers) HandleCompare(w http.ResponseWriter, r *http.Request)
HandleCompare handles POST /api/v1/compare
func (*Handlers) HandleDeleteACLRule ¶
func (h *Handlers) HandleDeleteACLRule(w http.ResponseWriter, r *http.Request)
HandleDeleteACLRule handles DELETE /api/v1/acl/rules/{index}
func (*Handlers) HandleDeleteEntry ¶
func (h *Handlers) HandleDeleteEntry(w http.ResponseWriter, r *http.Request)
HandleDeleteEntry handles DELETE /api/v1/entries/{dn}
func (*Handlers) HandleDisableEntry ¶
func (h *Handlers) HandleDisableEntry(w http.ResponseWriter, r *http.Request)
HandleDisableEntry handles POST /api/v1/entries/{dn}/disable
func (*Handlers) HandleEnableEntry ¶
func (h *Handlers) HandleEnableEntry(w http.ResponseWriter, r *http.Request)
HandleEnableEntry handles POST /api/v1/entries/{dn}/enable
func (*Handlers) HandleExportLogs ¶
func (h *Handlers) HandleExportLogs(w http.ResponseWriter, r *http.Request)
HandleExportLogs handles GET /api/v1/logs/export
func (*Handlers) HandleGetACL ¶
func (h *Handlers) HandleGetACL(w http.ResponseWriter, r *http.Request)
HandleGetACL handles GET /api/v1/acl
func (*Handlers) HandleGetACLRule ¶
func (h *Handlers) HandleGetACLRule(w http.ResponseWriter, r *http.Request)
HandleGetACLRule handles GET /api/v1/acl/rules/{index}
func (*Handlers) HandleGetACLRules ¶
func (h *Handlers) HandleGetACLRules(w http.ResponseWriter, r *http.Request)
HandleGetACLRules handles GET /api/v1/acl/rules
func (*Handlers) HandleGetConfig ¶
func (h *Handlers) HandleGetConfig(w http.ResponseWriter, r *http.Request)
HandleGetConfig handles GET /api/v1/config
func (*Handlers) HandleGetConfigSection ¶
func (h *Handlers) HandleGetConfigSection(w http.ResponseWriter, r *http.Request)
HandleGetConfigSection handles GET /api/v1/config/{section}
func (*Handlers) HandleGetEntry ¶
func (h *Handlers) HandleGetEntry(w http.ResponseWriter, r *http.Request)
HandleGetEntry handles GET /api/v1/entries/{dn}
func (*Handlers) HandleGetLockStatus ¶
func (h *Handlers) HandleGetLockStatus(w http.ResponseWriter, r *http.Request)
HandleGetLockStatus handles GET /api/v1/entries/{dn}/lock-status
func (*Handlers) HandleGetLogArchiveStats ¶ added in v1.1.0
func (h *Handlers) HandleGetLogArchiveStats(w http.ResponseWriter, r *http.Request)
HandleGetLogArchiveStats handles GET /api/v1/logs/archives/stats
func (*Handlers) HandleGetLogArchives ¶ added in v1.1.0
func (h *Handlers) HandleGetLogArchives(w http.ResponseWriter, r *http.Request)
HandleGetLogArchives handles GET /api/v1/logs/archives
func (*Handlers) HandleGetLogStats ¶
func (h *Handlers) HandleGetLogStats(w http.ResponseWriter, r *http.Request)
HandleGetLogStats handles GET /api/v1/logs/stats
func (*Handlers) HandleGetLogs ¶
func (h *Handlers) HandleGetLogs(w http.ResponseWriter, r *http.Request)
HandleGetLogs handles GET /api/v1/logs
func (*Handlers) HandleGetPublicConfig ¶
func (h *Handlers) HandleGetPublicConfig(w http.ResponseWriter, r *http.Request)
HandleGetPublicConfig handles GET /api/v1/config/public (no auth required)
func (*Handlers) HandleHealth ¶
func (h *Handlers) HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth handles GET /api/v1/health
func (*Handlers) HandleInternalLog ¶ added in v1.1.0
func (h *Handlers) HandleInternalLog(w http.ResponseWriter, r *http.Request)
HandleInternalLog handles POST /api/v1/internal/log This endpoint receives log entries forwarded from follower nodes.
func (*Handlers) HandleModifyDN ¶
func (h *Handlers) HandleModifyDN(w http.ResponseWriter, r *http.Request)
HandleModifyDN handles POST /api/v1/entries/{dn}/move
func (*Handlers) HandleModifyEntry ¶
func (h *Handlers) HandleModifyEntry(w http.ResponseWriter, r *http.Request)
HandleModifyEntry handles PUT/PATCH /api/v1/entries/{dn}
func (*Handlers) HandleReloadACL ¶
func (h *Handlers) HandleReloadACL(w http.ResponseWriter, r *http.Request)
HandleReloadACL handles POST /api/v1/acl/reload
func (*Handlers) HandleReloadConfig ¶
func (h *Handlers) HandleReloadConfig(w http.ResponseWriter, r *http.Request)
HandleReloadConfig handles POST /api/v1/config/reload
func (*Handlers) HandleSaveACL ¶
func (h *Handlers) HandleSaveACL(w http.ResponseWriter, r *http.Request)
HandleSaveACL handles POST /api/v1/acl/save
func (*Handlers) HandleSaveConfig ¶
func (h *Handlers) HandleSaveConfig(w http.ResponseWriter, r *http.Request)
HandleSaveConfig handles POST /api/v1/config/save
func (*Handlers) HandleSearch ¶
func (h *Handlers) HandleSearch(w http.ResponseWriter, r *http.Request)
HandleSearch handles GET /api/v1/search
func (*Handlers) HandleSetDefaultPolicy ¶
func (h *Handlers) HandleSetDefaultPolicy(w http.ResponseWriter, r *http.Request)
HandleSetDefaultPolicy handles PUT /api/v1/acl/default
func (*Handlers) HandleStats ¶ added in v1.0.2
func (h *Handlers) HandleStats(w http.ResponseWriter, r *http.Request)
HandleStats handles GET /api/v1/stats
func (*Handlers) HandleStreamSearch ¶
func (h *Handlers) HandleStreamSearch(w http.ResponseWriter, r *http.Request)
HandleStreamSearch handles GET /api/v1/search/stream
func (*Handlers) HandleUnlockEntry ¶
func (h *Handlers) HandleUnlockEntry(w http.ResponseWriter, r *http.Request)
HandleUnlockEntry handles POST /api/v1/entries/{dn}/unlock
func (*Handlers) HandleUpdateACLRule ¶
func (h *Handlers) HandleUpdateACLRule(w http.ResponseWriter, r *http.Request)
HandleUpdateACLRule handles PUT /api/v1/acl/rules/{index}
func (*Handlers) HandleUpdateConfigSection ¶
func (h *Handlers) HandleUpdateConfigSection(w http.ResponseWriter, r *http.Request)
HandleUpdateConfigSection handles PATCH /api/v1/config/{section}
func (*Handlers) HandleValidateACL ¶
func (h *Handlers) HandleValidateACL(w http.ResponseWriter, r *http.Request)
HandleValidateACL handles POST /api/v1/acl/validate
func (*Handlers) HandleValidateConfig ¶
func (h *Handlers) HandleValidateConfig(w http.ResponseWriter, r *http.Request)
HandleValidateConfig handles POST /api/v1/config/validate
func (*Handlers) IncrementConnections ¶
func (h *Handlers) IncrementConnections()
IncrementConnections increments active connection count.
func (*Handlers) SetACLManager ¶
SetACLManager sets the ACL manager for ACL-related endpoints.
func (*Handlers) SetClusterBackend ¶ added in v1.1.0
func (h *Handlers) SetClusterBackend(cb *raft.ClusterBackend)
SetClusterBackend sets the cluster backend for cluster mode.
func (*Handlers) SetConfigManager ¶
func (h *Handlers) SetConfigManager(m *config.ConfigManager)
SetConfigManager sets the config manager for config-related endpoints.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Version string `json:"version"`
Uptime string `json:"uptime"`
UptimeSecs int64 `json:"uptimeSecs"`
StartTime time.Time `json:"startTime"`
Connections int `json:"connections"`
Requests int64 `json:"requests"`
}
HealthResponse represents a health check response.
type InternalLogRequest ¶ added in v1.1.0
type InternalLogRequest struct {
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
Source string `json:"source,omitempty"`
User string `json:"user,omitempty"`
RequestID string `json:"request_id,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
}
InternalLogRequest represents a log entry forwarded from another node.
type JWTClaims ¶
type JWTClaims struct {
DN string `json:"dn"`
IssuedAt int64 `json:"iat"`
ExpiresAt int64 `json:"exp"`
}
JWTClaims represents JWT claims.
type LogQueryRequest ¶
type LogQueryRequest struct {
Level string `json:"level,omitempty"`
RequestID string `json:"request_id,omitempty"`
StartTime string `json:"start_time,omitempty"`
EndTime string `json:"end_time,omitempty"`
Search string `json:"search,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
}
LogQueryRequest represents a log query request.
type LogQueryResponse ¶
type LogQueryResponse struct {
Entries []logging.LogEntry `json:"entries"`
TotalCount int `json:"total_count"`
Offset int `json:"offset"`
Limit int `json:"limit"`
HasMore bool `json:"has_more"`
}
LogQueryResponse represents a log query response.
type LogStatsResponse ¶
type LogStatsResponse struct {
TotalEntries int `json:"total_entries"`
MaxEntries int `json:"max_entries"`
ByLevel map[string]int `json:"by_level"`
OldestEntry string `json:"oldest_entry,omitempty"`
NewestEntry string `json:"newest_entry,omitempty"`
}
LogStatsResponse represents log statistics response.
type Middleware ¶
Middleware is a function that wraps an http.Handler.
func AdminOnlyMiddleware ¶
func AdminOnlyMiddleware(adminDNs []string, adminPaths []string, excludePaths []string) Middleware
AdminOnlyMiddleware restricts access to admin users only. adminDNs is a list of DNs that are considered admins. excludePaths are paths that should not require admin access even if they match adminPaths prefix.
func AuthMiddleware ¶
func AuthMiddleware(auth *Authenticator, excludePaths []string) Middleware
AuthMiddleware validates JWT or Basic auth.
func CORSMiddleware ¶
func CORSMiddleware(allowedOrigins []string) Middleware
CORSMiddleware handles CORS headers.
func ConnectionTrackingMiddleware ¶
func ConnectionTrackingMiddleware(handlers *Handlers) Middleware
ConnectionTrackingMiddleware tracks active connections.
func LoggingMiddleware ¶
func LoggingMiddleware(logger logging.Logger) Middleware
LoggingMiddleware logs HTTP requests. Note: Detailed audit logs are written by handlers. This middleware only logs errors.
func RateLimitMiddleware ¶
func RateLimitMiddleware(requestsPerSecond int) Middleware
RateLimitMiddleware limits request rate per IP.
func RecoveryMiddleware ¶
func RecoveryMiddleware(logger logging.Logger) Middleware
RecoveryMiddleware recovers from panics.
type ModifyChange ¶
type ModifyChange struct {
Operation string `json:"operation"`
Attribute string `json:"attribute"`
Values []string `json:"values"`
}
ModifyChange represents a single modification.
type ModifyDNRequest ¶
type ModifyDNRequest struct {
NewRDN string `json:"newRDN"`
DeleteOldRDN bool `json:"deleteOldRDN"`
NewSuperior string `json:"newSuperior,omitempty"`
}
ModifyDNRequest represents a modifyDN request.
type ModifyRequest ¶
type ModifyRequest struct {
Changes []ModifyChange `json:"changes"`
}
ModifyRequest represents a modify request.
type OperationStats ¶ added in v1.0.2
type OperationStats struct {
Binds int64 `json:"binds"`
Searches int64 `json:"searches"`
Adds int64 `json:"adds"`
Modifies int64 `json:"modifies"`
Deletes int64 `json:"deletes"`
Compares int64 `json:"compares"`
}
OperationStats contains LDAP operation statistics.
type Route ¶
type Route struct {
Method string
Pattern string
Handler http.HandlerFunc
}
Route represents a single route.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a simple HTTP router.
func (*Router) DELETE ¶
func (r *Router) DELETE(pattern string, handler http.HandlerFunc)
DELETE registers a DELETE route.
func (*Router) GET ¶
func (r *Router) GET(pattern string, handler http.HandlerFunc)
GET registers a GET route.
func (*Router) Handle ¶
func (r *Router) Handle(method, pattern string, handler http.HandlerFunc)
Handle registers a route.
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(pattern string, handler http.HandlerFunc)
OPTIONS registers an OPTIONS route.
func (*Router) PATCH ¶
func (r *Router) PATCH(pattern string, handler http.HandlerFunc)
PATCH registers a PATCH route.
func (*Router) POST ¶
func (r *Router) POST(pattern string, handler http.HandlerFunc)
POST registers a POST route.
func (*Router) PUT ¶
func (r *Router) PUT(pattern string, handler http.HandlerFunc)
PUT registers a PUT route.
type SearchRequest ¶
type SearchRequest struct {
BaseDN string `json:"baseDN"`
Scope string `json:"scope"`
Filter string `json:"filter"`
Attributes []string `json:"attributes"`
SizeLimit int `json:"sizeLimit"`
TimeLimit int `json:"timeLimit"`
Offset int `json:"offset"`
Limit int `json:"limit"`
}
SearchRequest represents a search request (for POST-based search).
type SearchResponse ¶
type SearchResponse struct {
Entries []*Entry `json:"entries"`
TotalCount int `json:"totalCount"`
Offset int `json:"offset"`
Limit int `json:"limit"`
HasMore bool `json:"hasMore"`
}
SearchResponse represents a search response.
type SecurityStats ¶ added in v1.0.2
type SecurityStats struct {
LockedAccounts int `json:"lockedAccounts"`
DisabledAccounts int `json:"disabledAccounts"`
FailedLogins24h int `json:"failedLogins24h"`
}
SecurityStats contains security-related statistics.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the REST API server.
func NewServer ¶
func NewServer(cfg *ServerConfig, be *backend.ObaBackend, logger logging.Logger) *Server
NewServer creates a new REST server.
func (*Server) GetCORSOrigins ¶
GetCORSOrigins returns the current CORS origins.
func (*Server) GetRateLimit ¶
GetRateLimit returns the current rate limit.
func (*Server) GetTokenTTL ¶
GetTokenTTL returns the current token TTL.
func (*Server) SetACLManager ¶
SetACLManager sets the ACL manager for ACL-related endpoints.
func (*Server) SetCORSOrigins ¶
SetCORSOrigins updates the allowed CORS origins at runtime.
func (*Server) SetClusterBackend ¶ added in v1.1.0
func (s *Server) SetClusterBackend(cb *raft.ClusterBackend)
SetClusterBackend sets the cluster backend for cluster-related endpoints.
func (*Server) SetConfigManager ¶
func (s *Server) SetConfigManager(m *config.ConfigManager)
SetConfigManager sets the config manager for config-related endpoints.
func (*Server) SetRateLimit ¶
SetRateLimit updates the rate limit at runtime.
func (*Server) SetTokenTTL ¶
SetTokenTTL updates the JWT token TTL at runtime.
type ServerConfig ¶
type ServerConfig struct {
Address string
TLSAddress string
TLSCert string
TLSKey string
JWTSecret string
TokenTTL time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
RateLimit int
CORSOrigins []string
AdminDNs []string
}
ServerConfig holds REST server configuration.
func DefaultServerConfig ¶
func DefaultServerConfig() *ServerConfig
DefaultServerConfig returns default configuration.
type StatsResponse ¶ added in v1.0.2
type StatsResponse struct {
// Server stats
Status string `json:"status"`
Version string `json:"version"`
Uptime string `json:"uptime"`
UptimeSecs int64 `json:"uptimeSecs"`
StartTime time.Time `json:"startTime"`
Connections int `json:"connections"`
Requests int64 `json:"requests"`
Timezone string `json:"timezone"`
// Storage stats
Storage StorageStats `json:"storage"`
// Security stats
Security SecurityStats `json:"security"`
// System stats
System SystemStats `json:"system"`
// LDAP operation stats
Operations OperationStats `json:"operations"`
}
StatsResponse represents server statistics.
type StorageStats ¶ added in v1.0.2
type StorageStats struct {
EntryCount uint64 `json:"entryCount"`
IndexCount int `json:"indexCount"`
TotalPages uint64 `json:"totalPages"`
UsedPages uint64 `json:"usedPages"`
FreePages uint64 `json:"freePages"`
BufferPoolSize int `json:"bufferPoolSize"`
DirtyPages int `json:"dirtyPages"`
ActiveTransactions int `json:"activeTransactions"`
WALSize uint64 `json:"walSize"`
DatabaseSizeBytes int64 `json:"databaseSizeBytes"`
}
StorageStats contains storage-related statistics.
type SystemStats ¶ added in v1.0.2
type SystemStats struct {
GoRoutines int `json:"goRoutines"`
MemoryAlloc uint64 `json:"memoryAlloc"`
MemoryTotal uint64 `json:"memoryTotal"`
MemorySys uint64 `json:"memorySys"`
NumGC uint32 `json:"numGC"`
NumCPU int `json:"numCPU"`
}
SystemStats contains system-related statistics.