forked from baron/baron-sso
헬스체크 추가
This commit is contained in:
@@ -49,16 +49,12 @@ func GenerateSecureToken(length int) string {
|
||||
return hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
func NewAuthHandler() *AuthHandler {
|
||||
redisService, err := service.NewRedisService()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to connect to Redis: %v", err)
|
||||
}
|
||||
|
||||
func NewAuthHandler(redisService *service.RedisService) *AuthHandler {
|
||||
projectID := os.Getenv("DESCOPE_PROJECT_ID")
|
||||
managementKey := os.Getenv("DESCOPE_MANAGEMENT_KEY")
|
||||
|
||||
var descopeClient *client.DescopeClient
|
||||
var err error
|
||||
if projectID != "" {
|
||||
descopeClient, err = client.NewWithConfig(&client.Config{
|
||||
ProjectID: projectID,
|
||||
|
||||
@@ -79,3 +79,10 @@ func (r *ClickHouseRepository) Create(log *domain.AuditLog) error {
|
||||
log.Details,
|
||||
)
|
||||
}
|
||||
|
||||
func (r *ClickHouseRepository) Ping(ctx context.Context) error {
|
||||
if r.conn == nil {
|
||||
return fmt.Errorf("clickhouse connection is nil")
|
||||
}
|
||||
return r.conn.Ping(ctx)
|
||||
}
|
||||
|
||||
@@ -33,6 +33,13 @@ func NewRedisService() (*RedisService, error) {
|
||||
return &RedisService{Client: rdb}, nil
|
||||
}
|
||||
|
||||
func (s *RedisService) Ping(ctx context.Context) error {
|
||||
if s.Client == nil {
|
||||
return os.ErrInvalid
|
||||
}
|
||||
return s.Client.Ping(ctx).Err()
|
||||
}
|
||||
|
||||
// StoreVerificationCode saves the SMS verification code with a 3-minute expiration
|
||||
func (s *RedisService) StoreVerificationCode(phone, code string) error {
|
||||
// Key format: "sms_verify:01012345678"
|
||||
|
||||
Reference in New Issue
Block a user