Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateAPIKey() (string, error)
- func HashAPIKey(key string) string
- type APIKey
- type APIKeyStore
- func (s *APIKeyStore) Create(name string) (string, *APIKey, error)
- func (s *APIKeyStore) Delete(id int) error
- func (s *APIKeyStore) GetByHash(keyHash string) (*APIKey, error)
- func (s *APIKeyStore) List() ([]*APIKey, error)
- func (s *APIKeyStore) UpdateLastUsed(id int) error
- func (s *APIKeyStore) ValidateAPIKey(rawKey string) (*APIKey, error)
- type Instance
- type InstanceStore
- func (s *InstanceStore) Create(name, rawHost, username, password string, basicUsername, basicPassword *string) (*Instance, error)
- func (s *InstanceStore) Delete(id int) error
- func (s *InstanceStore) Get(id int) (*Instance, error)
- func (s *InstanceStore) GetDecryptedBasicPassword(instance *Instance) (*string, error)
- func (s *InstanceStore) GetDecryptedPassword(instance *Instance) (string, error)
- func (s *InstanceStore) List(activeOnly bool) ([]*Instance, error)
- func (s *InstanceStore) Update(id int, name, rawHost, username, password string, ...) (*Instance, error)
- func (s *InstanceStore) UpdateActive(id int, isActive bool) error
- func (s *InstanceStore) UpdateLastConnected(id int) error
- type ThemeLicense
- type User
- type UserStore
Constants ¶
View Source
const ( LicenseStatusActive = "active" LicenseStatusExpired = "expired" LicenseStatusInvalid = "invalid" )
LicenseStatus constants
Variables ¶
View Source
var ErrAPIKeyNotFound = errors.New("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 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) Delete ¶
func (s *APIKeyStore) Delete(id int) error
func (*APIKeyStore) List ¶
func (s *APIKeyStore) List() ([]*APIKey, error)
func (*APIKeyStore) UpdateLastUsed ¶
func (s *APIKeyStore) UpdateLastUsed(id int) error
func (*APIKeyStore) ValidateAPIKey ¶
func (s *APIKeyStore) ValidateAPIKey(rawKey string) (*APIKey, error)
ValidateAPIKey validates a raw API key and returns the associated APIKey if valid
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:"-"`
IsActive bool `json:"is_active"`
LastConnectedAt *time.Time `json:"last_connected_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type InstanceStore ¶
type InstanceStore struct {
// contains filtered or unexported fields
}
func NewInstanceStore ¶
func NewInstanceStore(db *sql.DB, encryptionKey []byte) (*InstanceStore, error)
func (*InstanceStore) Create ¶
func (s *InstanceStore) Create(name, rawHost, username, password string, basicUsername, basicPassword *string) (*Instance, error)
func (*InstanceStore) Delete ¶
func (s *InstanceStore) Delete(id int) 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
func (*InstanceStore) UpdateActive ¶
func (s *InstanceStore) UpdateActive(id int, isActive bool) error
func (*InstanceStore) UpdateLastConnected ¶
func (s *InstanceStore) UpdateLastConnected(id int) error
type ThemeLicense ¶
type ThemeLicense struct {
ID int `json:"id" db:"id"`
LicenseKey string `json:"licenseKey" db:"license_key"`
ThemeName string `json:"themeName" db:"theme_name"`
Status string `json:"status" db:"status"`
ActivatedAt time.Time `json:"activatedAt" db:"activated_at"`
ExpiresAt *time.Time `json:"expiresAt,omitempty" db:"expires_at"`
LastValidated time.Time `json:"lastValidated" db:"last_validated"`
PolarCustomerID *string `json:"polarCustomerId,omitempty" db:"polar_customer_id"`
PolarProductID *string `json:"polarProductId,omitempty" db:"polar_product_id"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}
ThemeLicense represents a theme license key in the database
func (*ThemeLicense) IsValid ¶
func (tl *ThemeLicense) IsValid() bool
IsValid returns true if the license is currently valid
func (*ThemeLicense) IsValidOffline ¶
func (tl *ThemeLicense) IsValidOffline() bool
IsValidOffline returns true if the license is valid for offline use Allows 7 days grace period since last validation
type UserStore ¶
type UserStore struct {
// contains filtered or unexported fields
}
func NewUserStore ¶
func (*UserStore) UpdatePassword ¶
Click to show internal directories.
Click to hide internal directories.