40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
"kra/internal/biz/system"
|
|
"time"
|
|
)
|
|
|
|
type SecurityService struct {
|
|
uc *system.SecurityUsecase
|
|
}
|
|
|
|
func NewSecurityService(uc *system.SecurityUsecase) *SecurityService {
|
|
return &SecurityService{uc: uc}
|
|
}
|
|
|
|
func (s *SecurityService) EnsureLoginIPCounter(ctx context.Context, ip string, expiration time.Duration) (int, error) {
|
|
return s.uc.EnsureLoginIPCounter(ctx, ip, expiration)
|
|
}
|
|
|
|
func (s *SecurityService) IncrementRateLimit(ctx context.Context, key string, expiration time.Duration) (int64, error) {
|
|
return s.uc.IncrementRateLimit(ctx, key, expiration)
|
|
}
|
|
|
|
func (s *SecurityService) SetCaptcha(ctx context.Context, id, value string, expiration time.Duration) error {
|
|
return s.uc.SetCaptcha(ctx, id, value, expiration)
|
|
}
|
|
|
|
func (s *SecurityService) GetCaptcha(ctx context.Context, id string) (string, bool, error) {
|
|
return s.uc.GetCaptcha(ctx, id)
|
|
}
|
|
|
|
func (s *SecurityService) DeleteCaptcha(ctx context.Context, id string) error {
|
|
return s.uc.DeleteCaptcha(ctx, id)
|
|
}
|
|
|
|
func (s *SecurityService) CaptchaSettings() system.CaptchaSettings {
|
|
return s.uc.CaptchaRuntimeSettings()
|
|
}
|