services

package
v0.0.0-...-605a81f Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSecretNotFound = errors.New("secret not found")
	ErrSecretExpired  = errors.New("secret has expired")
)
View Source
var (
	ErrUserNotFound       = errors.New("user not found")
	ErrInvalidCredentials = errors.New("invalid credentials")
)
View Source
var (
	ErrPolicyNotFound = fmt.Errorf("policy not found")
)
View Source
var (
	ErrTOTPNotFound = errors.New("TOTP not found")
)

Functions

This section is empty.

Types

type AuditService

type AuditService struct {
	// contains filtered or unexported fields
}

func NewAuditService

func NewAuditService(db *gorm.DB) *AuditService

func (*AuditService) CleanupOldLogs

func (s *AuditService) CleanupOldLogs(retentionDays int) error

func (*AuditService) GetAuditLogs

func (s *AuditService) GetAuditLogs(userID *uuid.UUID, limit, offset int) ([]model.AuditLog, error)

func (*AuditService) GetAuditLogsByResource

func (s *AuditService) GetAuditLogsByResource(resource, resourceID string, limit, offset int) ([]model.AuditLog, error)

func (*AuditService) LogAction

func (s *AuditService) LogAction(userID uuid.UUID, action, resource, resourceID string, success bool, details string) error

func (*AuditService) LogAnonymousAction

func (s *AuditService) LogAnonymousAction(action, resource, resourceID, ipAddress, userAgent string, success bool, details string) error

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

func NewAuthService

func NewAuthService(userService *UserService, config *config.JWTConfig) *AuthService

func (*AuthService) GetSession

func (s *AuthService) GetSession(userID uuid.UUID) (*model.SessionResponse, error)

func (*AuthService) Login

func (s *AuthService) Login(email, password string) (*model.LoginResponse, error)

func (*AuthService) ValidateToken

func (s *AuthService) ValidateToken(tokenString string) (*uuid.UUID, error)

type HTTPClient

type HTTPClient struct{}

func (*HTTPClient) GetStatus

func (c *HTTPClient) GetStatus(config *model.ProtocolConfig) (*model.ProtocolStatus, error)

func (*HTTPClient) Test

type HTTPSClient

type HTTPSClient struct{}

func (*HTTPSClient) GetStatus

func (c *HTTPSClient) GetStatus(config *model.ProtocolConfig) (*model.ProtocolStatus, error)

func (*HTTPSClient) Test

type NetworkService

type NetworkService struct {
	// contains filtered or unexported fields
}

func NewNetworkService

func NewNetworkService(db *gorm.DB) *NetworkService

func (*NetworkService) CreateNetwork

func (s *NetworkService) CreateNetwork(req *model.NetworkRequest) (*model.Network, error)

func (*NetworkService) DeleteNetwork

func (s *NetworkService) DeleteNetwork(id uint) error

func (*NetworkService) GetNetwork

func (s *NetworkService) GetNetwork(id uint) (*model.Network, error)

func (*NetworkService) GetNetworkByName

func (s *NetworkService) GetNetworkByName(name string) (*model.Network, error)

func (*NetworkService) GetNetworks

func (s *NetworkService) GetNetworks() ([]model.Network, error)

func (*NetworkService) GetProtocolStatus

func (s *NetworkService) GetProtocolStatus(id uint) (*model.ProtocolStatus, error)

func (*NetworkService) GetSupportedProtocols

func (s *NetworkService) GetSupportedProtocols() []model.ProtocolType

func (*NetworkService) TestProtocol

func (*NetworkService) UpdateNetwork

func (s *NetworkService) UpdateNetwork(id uint, req *model.NetworkRequest) (*model.Network, error)

type PolicyService

type PolicyService struct {
	// contains filtered or unexported fields
}

func NewPolicyService

func NewPolicyService(db *gorm.DB) *PolicyService

func (*PolicyService) CheckAccess

func (s *PolicyService) CheckAccess(userID uuid.UUID, resource, action string) (bool, error)

func (*PolicyService) CreatePolicy

func (s *PolicyService) CreatePolicy(policy *model.Policy, userID uuid.UUID) error

func (*PolicyService) DeletePolicy

func (s *PolicyService) DeletePolicy(id uuid.UUID, userID uuid.UUID) error

func (*PolicyService) GetPoliciesByUserID

func (s *PolicyService) GetPoliciesByUserID(userID uuid.UUID) ([]model.Policy, error)

func (*PolicyService) GetPolicyByID

func (s *PolicyService) GetPolicyByID(id uuid.UUID, userID uuid.UUID) (*model.Policy, error)

func (*PolicyService) UpdatePolicy

func (s *PolicyService) UpdatePolicy(policy *model.Policy) error

type ProtocolClient

type ProtocolClient interface {
	Test(config *model.ProtocolConfig) (*model.ProtocolTestResponse, error)
	GetStatus(config *model.ProtocolConfig) (*model.ProtocolStatus, error)
}

type SNMPCredentials

type SNMPCredentials struct {
	Community     string `json:"community"`
	Version       string `json:"version"` // "v1", "v2c", "v3"
	Username      string `json:"username,omitempty"`
	AuthProtocol  string `json:"auth_protocol,omitempty"`
	AuthPassword  string `json:"auth_password,omitempty"`
	PrivProtocol  string `json:"priv_protocol,omitempty"`
	PrivPassword  string `json:"priv_password,omitempty"`
	SecurityLevel string `json:"security_level,omitempty"`
}

type SNMPRequest

type SNMPRequest struct {
	Target      string          `json:"target"`
	Port        int             `json:"port"`
	OIDs        []string        `json:"oids"`
	Credentials SNMPCredentials `json:"credentials"`
}

type SNMPResponse

type SNMPResponse struct {
	Target    string           `json:"target"`
	Success   bool             `json:"success"`
	Variables []gosnmp.SnmpPDU `json:"variables"`
	Error     string           `json:"error,omitempty"`
	Timestamp time.Time        `json:"timestamp"`
}

type SNMPService

type SNMPService struct {
	// contains filtered or unexported fields
}

func NewSNMPService

func NewSNMPService() *SNMPService

func (*SNMPService) GetSNMPData

func (s *SNMPService) GetSNMPData(req SNMPRequest) (*SNMPResponse, error)

func (*SNMPService) TestConnection

func (s *SNMPService) TestConnection(req SNMPRequest) error

func (*SNMPService) WalkSNMP

func (s *SNMPService) WalkSNMP(req SNMPRequest) (*SNMPWalkResponse, error)

type SNMPWalkResponse

type SNMPWalkResponse struct {
	Target    string                   `json:"target"`
	Success   bool                     `json:"success"`
	Results   []map[string]interface{} `json:"results"`
	Error     string                   `json:"error,omitempty"`
	Timestamp time.Time                `json:"timestamp"`
}

type SecretService

type SecretService struct {
	// contains filtered or unexported fields
}

func NewSecretService

func NewSecretService(db *gorm.DB, encryptionKey string, kdfSalt string, kdfIter int, auditService *AuditService) *SecretService

func (*SecretService) CreateSecret

func (s *SecretService) CreateSecret(secret *model.Secret, userID uuid.UUID) error

func (*SecretService) DeleteSecret

func (s *SecretService) DeleteSecret(id uuid.UUID, userID uuid.UUID) error

func (*SecretService) GetSecretByID

func (s *SecretService) GetSecretByID(id uuid.UUID, userID uuid.UUID) (*model.Secret, error)

func (*SecretService) GetSecretsByUserID

func (s *SecretService) GetSecretsByUserID(userID uuid.UUID) ([]model.Secret, error)

func (*SecretService) UpdateSecret

func (s *SecretService) UpdateSecret(id uuid.UUID, updates *model.UpdateSecretRequest, userID uuid.UUID) (*model.Secret, error)

type TCPClient

type TCPClient struct{}

func (*TCPClient) GetStatus

func (c *TCPClient) GetStatus(config *model.ProtocolConfig) (*model.ProtocolStatus, error)

func (*TCPClient) Test

type TOTPService

type TOTPService struct {
	// contains filtered or unexported fields
}

func NewTOTPService

func NewTOTPService(db *gorm.DB, auditService *AuditService) *TOTPService

func (*TOTPService) CreateTOTP

func (s *TOTPService) CreateTOTP(totp *model.TOTP, userID uuid.UUID) error

func (*TOTPService) DeleteTOTP

func (s *TOTPService) DeleteTOTP(id uuid.UUID, userID uuid.UUID) error

func (*TOTPService) GenerateCode

func (s *TOTPService) GenerateCode(id uuid.UUID, userID uuid.UUID) (*model.TOTPGenerateResponse, error)

func (*TOTPService) GetTOTPByID

func (s *TOTPService) GetTOTPByID(id uuid.UUID, userID uuid.UUID) (*model.TOTP, error)

func (*TOTPService) GetTOTPsByUserID

func (s *TOTPService) GetTOTPsByUserID(userID uuid.UUID) ([]model.TOTP, error)

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(db *gorm.DB) *UserService

func (*UserService) CreateUser

func (s *UserService) CreateUser(user *model.User) error

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(id uuid.UUID) error

func (*UserService) GetDB

func (s *UserService) GetDB() *gorm.DB

func (*UserService) GetUserByEmail

func (s *UserService) GetUserByEmail(email string) (*model.User, error)

func (*UserService) GetUserByID

func (s *UserService) GetUserByID(id uuid.UUID) (*model.User, error)

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(user *model.User) error

func (*UserService) ValidatePassword

func (s *UserService) ValidatePassword(user *model.User, password string) bool

Jump to

Keyboard shortcuts

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