Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateAPIKey() (string, error)
- func HashAPIKey(key string) string
- type APIKey
- type APIKeyStore
- func (s *APIKeyStore) Create(ctx context.Context, name string) (string, *APIKey, error)
- func (s *APIKeyStore) Delete(ctx context.Context, id int) error
- func (s *APIKeyStore) GetByHash(ctx context.Context, keyHash string) (*APIKey, error)
- func (s *APIKeyStore) List(ctx context.Context) ([]*APIKey, error)
- func (s *APIKeyStore) UpdateLastUsed(ctx context.Context, id int) error
- func (s *APIKeyStore) ValidateAPIKey(ctx context.Context, rawKey string) (*APIKey, error)
- type ClientAPIKey
- type ClientAPIKeyStore
- func (s *ClientAPIKeyStore) Create(ctx context.Context, clientName string, instanceID int) (string, *ClientAPIKey, error)
- func (s *ClientAPIKeyStore) Delete(ctx context.Context, id int) error
- func (s *ClientAPIKeyStore) DeleteByInstanceID(ctx context.Context, instanceID int) error
- func (s *ClientAPIKeyStore) GetAll(ctx context.Context) ([]*ClientAPIKey, error)
- func (s *ClientAPIKeyStore) GetByKeyHash(ctx context.Context, keyHash string) (*ClientAPIKey, error)
- func (s *ClientAPIKeyStore) UpdateLastUsed(ctx context.Context, keyHash string) error
- func (s *ClientAPIKeyStore) ValidateKey(ctx context.Context, rawKey string) (*ClientAPIKey, error)
- type Instance
- type InstanceError
- type InstanceErrorStore
- type InstanceStore
- func (s *InstanceStore) Create(ctx context.Context, name, rawHost, username, password string, ...) (*Instance, error)
- func (s *InstanceStore) Delete(ctx context.Context, id int) error
- func (s *InstanceStore) Get(ctx context.Context, id int) (*Instance, error)
- func (s *InstanceStore) GetDecryptedBasicPassword(instance *Instance) (*string, error)
- func (s *InstanceStore) GetDecryptedPassword(instance *Instance) (string, error)
- func (s *InstanceStore) List(ctx context.Context) ([]*Instance, error)
- func (s *InstanceStore) Update(ctx context.Context, id int, name, rawHost, username, password string, ...) (*Instance, error)
- type LicenseInfo
- type ProductLicense
- type User
- type UserStore
- func (s *UserStore) Create(ctx context.Context, username, passwordHash string) (*User, error)
- func (s *UserStore) Exists(ctx context.Context) (bool, error)
- func (s *UserStore) Get(ctx context.Context) (*User, error)
- func (s *UserStore) GetByUsername(ctx context.Context, username string) (*User, error)
- func (s *UserStore) UpdatePassword(ctx context.Context, passwordHash string) error
Constants ¶
View Source
const ( ErrorTypeConnection = "connection" ErrorTypeAuthentication = "authentication" ErrorTypeBan = "ban" ErrorTypeAPI = "api" )
Error types for categorization
View Source
const ( LicenseStatusActive = "active" LicenseStatusInvalid = "invalid" )
LicenseStatus constants
Variables ¶
View Source
var ErrAPIKeyNotFound = errors.New("api key not found")
View Source
var ErrClientAPIKeyNotFound = errors.New("client api key not found")
View Source
var ErrInstanceNotFound = errors.New("instance not found")
View Source
var ErrInvalidAPIKey = errors.New("invalid api key")
View Source
var (
ErrLicenseNotFound = errors.New("license not found")
)
View Source
var ErrUserAlreadyExists = errors.New("user already exists")
View Source
var ErrUserNotFound = errors.New("user not found")
Functions ¶
func HashAPIKey ¶
HashAPIKey creates a SHA256 hash of the API key
Types ¶
type APIKeyStore ¶
type APIKeyStore struct {
// contains filtered or unexported fields
}
func NewAPIKeyStore ¶
func NewAPIKeyStore(db *sql.DB) *APIKeyStore
func (*APIKeyStore) UpdateLastUsed ¶
func (s *APIKeyStore) UpdateLastUsed(ctx context.Context, id int) error
func (*APIKeyStore) ValidateAPIKey ¶
ValidateAPIKey validates a raw API key and returns the associated APIKey if valid
type ClientAPIKey ¶ added in v1.0.0
type ClientAPIKeyStore ¶ added in v1.0.0
type ClientAPIKeyStore struct {
// contains filtered or unexported fields
}
func NewClientAPIKeyStore ¶ added in v1.0.0
func NewClientAPIKeyStore(db *sql.DB) *ClientAPIKeyStore
func (*ClientAPIKeyStore) Create ¶ added in v1.0.0
func (s *ClientAPIKeyStore) Create(ctx context.Context, clientName string, instanceID int) (string, *ClientAPIKey, error)
func (*ClientAPIKeyStore) Delete ¶ added in v1.0.0
func (s *ClientAPIKeyStore) Delete(ctx context.Context, id int) error
func (*ClientAPIKeyStore) DeleteByInstanceID ¶ added in v1.0.0
func (s *ClientAPIKeyStore) DeleteByInstanceID(ctx context.Context, instanceID int) error
func (*ClientAPIKeyStore) GetAll ¶ added in v1.0.0
func (s *ClientAPIKeyStore) GetAll(ctx context.Context) ([]*ClientAPIKey, error)
func (*ClientAPIKeyStore) GetByKeyHash ¶ added in v1.0.0
func (s *ClientAPIKeyStore) GetByKeyHash(ctx context.Context, keyHash string) (*ClientAPIKey, error)
func (*ClientAPIKeyStore) UpdateLastUsed ¶ added in v1.0.0
func (s *ClientAPIKeyStore) UpdateLastUsed(ctx context.Context, keyHash string) error
func (*ClientAPIKeyStore) ValidateKey ¶ added in v1.0.0
func (s *ClientAPIKeyStore) ValidateKey(ctx context.Context, rawKey string) (*ClientAPIKey, error)
type Instance ¶
type Instance struct {
ID int `json:"id"`
Name string `json:"name"`
Host string `json:"host"`
Username string `json:"username"`
PasswordEncrypted string `json:"-"`
BasicUsername *string `json:"basic_username,omitempty"`
BasicPasswordEncrypted *string `json:"-"`
}
func (Instance) MarshalJSON ¶ added in v1.0.0
func (*Instance) UnmarshalJSON ¶ added in v1.0.0
type InstanceError ¶ added in v1.0.0
type InstanceErrorStore ¶ added in v1.0.0
type InstanceErrorStore struct {
// contains filtered or unexported fields
}
func NewInstanceErrorStore ¶ added in v1.0.0
func NewInstanceErrorStore(db *sql.DB) *InstanceErrorStore
func (*InstanceErrorStore) ClearErrors ¶ added in v1.0.0
func (s *InstanceErrorStore) ClearErrors(ctx context.Context, instanceID int) error
ClearErrors removes all errors for an instance (called on successful connection)
func (*InstanceErrorStore) GetRecentErrors ¶ added in v1.0.0
func (s *InstanceErrorStore) GetRecentErrors(ctx context.Context, instanceID int, limit int) ([]InstanceError, error)
GetRecentErrors retrieves the last N errors for an instance
func (*InstanceErrorStore) RecordError ¶ added in v1.0.0
RecordError stores an error for an instance with simple deduplication
type InstanceStore ¶
type InstanceStore struct {
// contains filtered or unexported fields
}
func NewInstanceStore ¶
func NewInstanceStore(db *sql.DB, encryptionKey []byte) (*InstanceStore, error)
func (*InstanceStore) GetDecryptedBasicPassword ¶
func (s *InstanceStore) GetDecryptedBasicPassword(instance *Instance) (*string, error)
GetDecryptedBasicPassword returns the decrypted basic auth password for an instance
func (*InstanceStore) GetDecryptedPassword ¶
func (s *InstanceStore) GetDecryptedPassword(instance *Instance) (string, error)
GetDecryptedPassword returns the decrypted password for an instance
type LicenseInfo ¶ added in v1.0.0
type LicenseInfo struct {
Key string `json:"key"`
ProductName string `json:"productName"`
CustomerID string `json:"customerId"`
ProductID string `json:"productId"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
Valid bool `json:"valid"`
ErrorMessage string `json:"errorMessage,omitempty"`
}
LicenseInfo contains license validation information
type ProductLicense ¶ added in v1.0.0
type ProductLicense struct {
ID int `json:"id"`
LicenseKey string `json:"licenseKey"`
ProductName string `json:"productName"`
Status string `json:"status"`
ActivatedAt time.Time `json:"activatedAt"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
LastValidated time.Time `json:"lastValidated"`
PolarCustomerID *string `json:"polarCustomerId,omitempty"`
PolarProductID *string `json:"polarProductId,omitempty"`
PolarActivationID string `json:"polarActivationId,omitempty"`
Username string `json:"username"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ProductLicense represents a product license in the database
type UserStore ¶
type UserStore struct {
// contains filtered or unexported fields
}
func NewUserStore ¶
func (*UserStore) GetByUsername ¶
Click to show internal directories.
Click to hide internal directories.