auth

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivateUserHandler added in v1.4.0

func ActivateUserHandler(c *gin.Context)

ActivateUserHandler activates a user (admin only)

func AdminRequiredMiddleware added in v1.4.0

func AdminRequiredMiddleware() gin.HandlerFunc

AdminRequiredMiddleware ensures the user is an admin

func AdminResetPasswordHandler added in v1.4.0

func AdminResetPasswordHandler(c *gin.Context)

AdminResetPasswordHandler resets any user's password (admin only)

func AdminUpdatePasswordHandler added in v1.4.0

func AdminUpdatePasswordHandler(c *gin.Context)

AdminUpdatePasswordHandler updates any user's password (admin only)

func AnalyzeBackupHandler added in v1.4.0

func AnalyzeBackupHandler(c *gin.Context)

AnalyzeBackupHandler analyzes a backup file and returns metadata without restoring (admin only)

func ApiKeyOrJWTMiddleware

func ApiKeyOrJWTMiddleware() gin.HandlerFunc

ApiKeyOrJWTMiddleware checks for either valid API key or valid JWT

func AuthRequired added in v1.4.0

func AuthRequired() bool

AuthRequired checks if API authentication is configured

func CheckAuthHandler

func CheckAuthHandler(c *gin.Context)

func CheckSingleUserPaired added in v1.4.0

func CheckSingleUserPaired() bool

CheckSingleUserPaired checks if rmapi.conf exists for single-user mode

func CleanupDataHandler added in v1.4.0

func CleanupDataHandler(c *gin.Context)

CleanupDataHandler performs database cleanup (admin only)

func CleanupExpiredAPIKeysHandler added in v1.4.0

func CleanupExpiredAPIKeysHandler(c *gin.Context)

CleanupExpiredAPIKeysHandler removes expired API keys (admin only)

func CreateAPIKeyHandler added in v1.4.0

func CreateAPIKeyHandler(c *gin.Context)

CreateAPIKeyHandler creates a new API key for the current user

func CreateBackupJobHandler added in v1.4.1

func CreateBackupJobHandler(c *gin.Context)

CreateBackupJobHandler creates a background backup job (admin only)

func DeactivateAPIKeyHandler added in v1.4.0

func DeactivateAPIKeyHandler(c *gin.Context)

DeactivateAPIKeyHandler deactivates an API key

func DeactivateUserHandler added in v1.4.0

func DeactivateUserHandler(c *gin.Context)

DeactivateUserHandler deactivates a user (admin only)

func DeleteAPIKeyHandler added in v1.4.0

func DeleteAPIKeyHandler(c *gin.Context)

DeleteAPIKeyHandler permanently deletes an API key

func DeleteBackupJobHandler added in v1.4.1

func DeleteBackupJobHandler(c *gin.Context)

DeleteBackupJobHandler deletes a backup job and its file

func DeleteCurrentUserHandler added in v1.4.0

func DeleteCurrentUserHandler(c *gin.Context)

DeleteCurrentUserHandler allows users to delete their own account

func DeleteRestoreUploadHandler added in v1.4.1

func DeleteRestoreUploadHandler(c *gin.Context)

DeleteRestoreUploadHandler deletes a restore upload and its file

func DeleteUserHandler added in v1.4.0

func DeleteUserHandler(c *gin.Context)

DeleteUserHandler deletes a user (admin only)

func DemoteUserHandler added in v1.4.0

func DemoteUserHandler(c *gin.Context)

DemoteUserHandler demotes an admin to user (admin only)

func DownloadBackupHandler added in v1.4.1

func DownloadBackupHandler(c *gin.Context)

DownloadBackupHandler downloads a completed backup file

func GetAPIKeyHandler added in v1.4.0

func GetAPIKeyHandler(c *gin.Context)

GetAPIKeyHandler returns a specific API key

func GetAPIKeyStatsHandler added in v1.4.0

func GetAPIKeyStatsHandler(c *gin.Context)

GetAPIKeyStatsHandler returns API key statistics (admin only)

func GetAPIKeysHandler added in v1.4.0

func GetAPIKeysHandler(c *gin.Context)

GetAPIKeysHandler returns all API keys for the current user

func GetAllAPIKeysHandler added in v1.4.0

func GetAllAPIKeysHandler(c *gin.Context)

GetAllAPIKeysHandler returns all API keys in the system (admin only)

func GetAuthMethod added in v1.4.0

func GetAuthMethod(c *gin.Context) string

GetAuthMethod returns the authentication method used

func GetBackupJobHandler added in v1.4.1

func GetBackupJobHandler(c *gin.Context)

GetBackupJobHandler returns a specific backup job

func GetBackupJobsHandler added in v1.4.1

func GetBackupJobsHandler(c *gin.Context)

GetBackupJobsHandler returns backup jobs for the admin user

func GetCurrentUser added in v1.4.0

func GetCurrentUser(c *gin.Context) *database.User

GetCurrentUser returns the current authenticated user

func GetCurrentUserHandler added in v1.4.0

func GetCurrentUserHandler(c *gin.Context)

GetCurrentUserHandler returns current user info

func GetCurrentUserID added in v1.4.0

func GetCurrentUserID(c *gin.Context) uuid.UUID

GetCurrentUserID returns the current authenticated user's ID

func GetCurrentUserStatsHandler added in v1.4.0

func GetCurrentUserStatsHandler(c *gin.Context)

GetCurrentUserStatsHandler returns current user's statistics

func GetRegistrationStatusHandler added in v1.4.0

func GetRegistrationStatusHandler(c *gin.Context)

GetRegistrationStatusHandler returns whether registration is enabled (public endpoint)

func GetRestoreUploadsHandler added in v1.4.1

func GetRestoreUploadsHandler(c *gin.Context)

GetRestoreUploadsHandler returns pending restore uploads for the admin user

func GetSystemSettingsHandler added in v1.4.0

func GetSystemSettingsHandler(c *gin.Context)

GetSystemSettingsHandler returns all system settings (admin only)

func GetSystemStatusHandler added in v1.4.0

func GetSystemStatusHandler(c *gin.Context)

GetSystemStatusHandler returns system status information (admin only)

func GetUISecret

func GetUISecret() string

GetUISecret returns the UI authentication secret for embedding in frontend

func GetUserHandler added in v1.4.0

func GetUserHandler(c *gin.Context)

GetUserHandler returns a specific user (admin only)

func GetUserStatsHandler added in v1.4.0

func GetUserStatsHandler(c *gin.Context)

GetUserStatsHandler returns user statistics (admin only)

func GetUsersHandler added in v1.4.0

func GetUsersHandler(c *gin.Context)

GetUsersHandler returns all users (admin only)

func HandlePairRequest added in v1.4.0

func HandlePairRequest(c *gin.Context)

HandlePairRequest handles pairing for both single-user and multi-user modes

func InitOIDC added in v1.4.0

func InitOIDC() error

InitOIDC initializes OIDC configuration from environment variables

func InitProxyAuth added in v1.4.0

func InitProxyAuth()

InitProxyAuth initializes proxy authentication configuration

func IsCurrentUserAdmin added in v1.4.0

func IsCurrentUserAdmin(c *gin.Context) bool

IsCurrentUserAdmin checks if the current user is an admin

func IsOIDCEnabled added in v1.4.0

func IsOIDCEnabled() bool

IsOIDCEnabled returns true if OIDC is configured and enabled

func IsOIDCGroupBasedAdminEnabled added in v1.4.1

func IsOIDCGroupBasedAdminEnabled() bool

func IsProxyAuthEnabled added in v1.4.0

func IsProxyAuthEnabled() bool

IsProxyAuthEnabled returns true if proxy authentication is configured

func LoginHandler

func LoginHandler(c *gin.Context)

func LogoutHandler

func LogoutHandler(c *gin.Context)

func MultiUserAuthMiddleware added in v1.4.0

func MultiUserAuthMiddleware() gin.HandlerFunc

MultiUserAuthMiddleware provides authentication for multi-user mode

func MultiUserCheckAuthHandler added in v1.4.0

func MultiUserCheckAuthHandler(c *gin.Context)

MultiUserCheckAuthHandler checks authentication for multi-user mode

func MultiUserLoginHandler added in v1.4.0

func MultiUserLoginHandler(c *gin.Context)

MultiUserLoginHandler handles login for multi-user mode

func OIDCAuthHandler added in v1.4.0

func OIDCAuthHandler(c *gin.Context)

OIDCAuthHandler initiates OIDC authentication flow

func OIDCCallbackHandler added in v1.4.0

func OIDCCallbackHandler(c *gin.Context)

OIDCCallbackHandler handles the OIDC callback

func OIDCLogoutHandler added in v1.4.0

func OIDCLogoutHandler(c *gin.Context)

OIDCLogoutHandler handles OIDC logout

func OptionalAuthMiddleware added in v1.4.0

func OptionalAuthMiddleware() gin.HandlerFunc

OptionalAuthMiddleware provides optional authentication

func PairRMAPIHandler added in v1.4.0

func PairRMAPIHandler(c *gin.Context)

PairRMAPIHandler pairs the current user with rmapi using a one-time code.

func PasswordResetConfirmHandler added in v1.4.0

func PasswordResetConfirmHandler(c *gin.Context)

PasswordResetConfirmHandler confirms password reset

func PasswordResetHandler added in v1.4.0

func PasswordResetHandler(c *gin.Context)

PasswordResetHandler initiates password reset

func PromoteUserHandler added in v1.4.0

func PromoteUserHandler(c *gin.Context)

PromoteUserHandler promotes a user to admin (admin only)

func ProxyAuthCheckHandler added in v1.4.0

func ProxyAuthCheckHandler(c *gin.Context)

ProxyAuthCheckHandler checks proxy authentication status

func ProxyAuthMiddleware added in v1.4.0

func ProxyAuthMiddleware() gin.HandlerFunc

ProxyAuthMiddleware handles proxy authentication

func PublicRegisterHandler added in v1.4.0

func PublicRegisterHandler(c *gin.Context)

PublicRegisterHandler handles public user registration (when enabled)

func RegisterHandler added in v1.4.0

func RegisterHandler(c *gin.Context)

RegisterHandler handles user registration (admin only)

func RequireAdmin added in v1.4.0

func RequireAdmin(c *gin.Context) (*database.User, bool)

RequireAdmin ensures the user is an admin and returns it

func RequireUser added in v1.4.0

func RequireUser(c *gin.Context) (*database.User, bool)

RequireUser ensures a user is authenticated and returns it

func RestoreDatabaseHandler added in v1.4.0

func RestoreDatabaseHandler(c *gin.Context)

RestoreDatabaseHandler initiates database restore from uploaded file (admin only)

func RunPair added in v1.4.0

func RunPair(stdout, stderr io.Writer) error

RunPair handles interactive pairing flow

func ServeIndexWithSecret added in v1.4.0

func ServeIndexWithSecret(c *gin.Context, uiFS fs.FS, secret string)

ServeIndexWithSecret serves index.html with injected secret

func SetPostPairingCallback added in v1.4.0

func SetPostPairingCallback(callback PostPairingCallback)

SetPostPairingCallback sets the callback to be called after successful pairing

func TestSMTPHandler added in v1.4.0

func TestSMTPHandler(c *gin.Context)

TestSMTPHandler tests SMTP configuration (admin only)

func UnpairRMAPIHandler added in v1.4.0

func UnpairRMAPIHandler(c *gin.Context)

UnpairRMAPIHandler removes the rmapi configuration for the current user.

func UpdateAPIKeyHandler added in v1.4.0

func UpdateAPIKeyHandler(c *gin.Context)

UpdateAPIKeyHandler updates an API key (name only)

func UpdateCurrentUserHandler added in v1.4.0

func UpdateCurrentUserHandler(c *gin.Context)

UpdateCurrentUserHandler updates the current user's profile

func UpdatePasswordHandler added in v1.4.0

func UpdatePasswordHandler(c *gin.Context)

UpdatePasswordHandler updates the current user's password

func UpdateSystemSettingHandler added in v1.4.0

func UpdateSystemSettingHandler(c *gin.Context)

UpdateSystemSettingHandler updates a system setting (admin only)

func UpdateUserHandler added in v1.4.0

func UpdateUserHandler(c *gin.Context)

UpdateUserHandler updates a user (admin only)

func UploadRestoreFileHandler added in v1.4.1

func UploadRestoreFileHandler(c *gin.Context)

UploadRestoreFileHandler uploads a restore file and returns upload ID (admin only)

Types

type APIKeyResponse added in v1.4.0

type APIKeyResponse struct {
	ID        uuid.UUID  `json:"id"`
	Name      string     `json:"name"`
	KeyPrefix string     `json:"key_prefix"`
	IsActive  bool       `json:"is_active"`
	LastUsed  *time.Time `json:"last_used,omitempty"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

APIKeyResponse represents an API key in responses

type AdminResetPasswordRequest added in v1.4.0

type AdminResetPasswordRequest struct {
	NewPassword string `json:"new_password" binding:"required,min=8"`
}

AdminResetPasswordRequest represents an admin password reset request

type AdminUpdatePasswordRequest added in v1.4.0

type AdminUpdatePasswordRequest struct {
	NewPassword string `json:"new_password" binding:"required,min=8"`
}

AdminUpdatePasswordRequest represents an admin password update request

type CreateAPIKeyRequest added in v1.4.0

type CreateAPIKeyRequest struct {
	Name      string `json:"name" binding:"required,min=1,max=100"`
	ExpiresAt *int64 `json:"expires_at,omitempty"` // Unix timestamp, optional
}

CreateAPIKeyRequest represents an API key creation request

type CreateAPIKeyResponse added in v1.4.0

type CreateAPIKeyResponse struct {
	APIKeyResponse
	APIKey string `json:"api_key"`
}

CreateAPIKeyResponse includes the full API key (only returned once)

type LoginRequest

type LoginRequest struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type OIDCConfig added in v1.4.0

type OIDCConfig struct {
	Issuer       string
	ClientID     string
	ClientSecret string
	RedirectURL  string
	Scopes       []string
}

type PasswordResetConfirmRequest added in v1.4.0

type PasswordResetConfirmRequest struct {
	Token    string `json:"token" binding:"required"`
	Password string `json:"password" binding:"required,min=8"`
}

PasswordResetConfirmRequest represents a password reset confirmation

type PasswordResetRequest added in v1.4.0

type PasswordResetRequest struct {
	Email string `json:"email" binding:"required,email"`
}

PasswordResetRequest represents a password reset request

type PostPairingCallback added in v1.4.0

type PostPairingCallback func(userID string, singleUserMode bool)

PostPairingCallback is called after successful pairing

func GetPostPairingCallback added in v1.4.0

func GetPostPairingCallback() PostPairingCallback

GetPostPairingCallback returns the current post-pairing callback

type RegisterRequest added in v1.4.0

type RegisterRequest struct {
	Username string `json:"username" binding:"required,min=3,max=50"`
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required,min=8"`
}

RegisterRequest represents a user registration request

type SelfDeleteRequest added in v1.4.0

type SelfDeleteRequest struct {
	CurrentPassword string `json:"current_password" binding:"required"`
	Confirmation    string `json:"confirmation" binding:"required"`
}

SelfDeleteRequest represents a self-service account deletion request

type UpdatePasswordRequest added in v1.4.0

type UpdatePasswordRequest struct {
	CurrentPassword string `json:"current_password" binding:"required"`
	NewPassword     string `json:"new_password" binding:"required,min=8"`
}

UpdatePasswordRequest represents a password update request

type UpdateUserRequest added in v1.4.0

type UpdateUserRequest struct {
	Email            *string  `json:"email,omitempty" binding:"omitempty,email"`
	RmapiHost        *string  `json:"rmapi_host,omitempty"`
	DefaultRmdir     *string  `json:"default_rmdir,omitempty"`
	CoverpageSetting *string  `json:"coverpage_setting,omitempty"`
	PageResolution   *string  `json:"page_resolution,omitempty"`
	PageDPI          *float64 `json:"page_dpi,omitempty"`
	IsAdmin          *bool    `json:"is_admin,omitempty"`
	IsActive         *bool    `json:"is_active,omitempty"`
}

UpdateUserRequest represents a user update request

type UserResponse added in v1.4.0

type UserResponse struct {
	ID               uuid.UUID  `json:"id"`
	Username         string     `json:"username"`
	Email            string     `json:"email"`
	IsAdmin          bool       `json:"is_admin"`
	IsActive         bool       `json:"is_active"`
	RmapiHost        string     `json:"rmapi_host,omitempty"`
	DefaultRmdir     string     `json:"default_rmdir"`
	CoverpageSetting string     `json:"coverpage_setting"`
	PageResolution   string     `json:"page_resolution,omitempty"`
	PageDPI          float64    `json:"page_dpi,omitempty"`
	RmapiPaired      bool       `json:"rmapi_paired"`
	CreatedAt        time.Time  `json:"created_at"`
	LastLogin        *time.Time `json:"last_login,omitempty"`
}

UserResponse represents a user in API responses

Jump to

Keyboard shortcuts

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