Skip to content

Commit

Permalink
Merge pull request #4 from speee/fix/lockout-duration
Browse files Browse the repository at this point in the history
make login lockout duration configurable
  • Loading branch information
kazuhisa-wada authored Dec 16, 2024
2 parents 1e67d35 + 00d6332 commit 7098f95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,5 @@ CREATE_TIDB_SERVICE_JOB_ENABLED=false

# Maximum number of submitted thread count in a ThreadPool for parallel node execution
MAX_SUBMIT_COUNT=100
# Lockout duration in seconds
LOGIN_LOCKOUT_DURATION=86400
5 changes: 5 additions & 0 deletions api/configs/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ class AuthConfig(BaseSettings):
default=60,
)

LOGIN_LOCKOUT_DURATION: PositiveInt = Field(
description="Time (in seconds) a user must wait before retrying login after exceeding the rate limit.",
default=86400,
)


class ModerationConfig(BaseSettings):
"""
Expand Down
2 changes: 1 addition & 1 deletion api/services/account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def add_login_error_rate_limit(email: str) -> None:
if count is None:
count = 0
count = int(count) + 1
redis_client.setex(key, 60 * 60 * 24, count)
redis_client.setex(key, dify_config.LOGIN_LOCKOUT_DURATION, count)

@staticmethod
def is_login_error_rate_limit(email: str) -> bool:
Expand Down

0 comments on commit 7098f95

Please sign in to comment.