Skip to content

Commit

Permalink
chore: change login white list name
Browse files Browse the repository at this point in the history
  • Loading branch information
erfjab committed Sep 3, 2024
1 parent f1395ee commit ae5b6a6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ UVICORN_PORT = 8000
# NOTIFY_LOGIN = True

## Whitelist of IPs/hosts to disable login notifications
# LOGIN_WHITE_LIST = '1.1.1.1,sub.domain.com,127.0.0.1'
# LOGIN_NOTIFY_WHITE_LIST = '1.1.1.1,127.0.0.1'

### for developers
# DOCS=True
Expand Down
4 changes: 2 additions & 2 deletions app/routers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from fastapi.security import OAuth2PasswordRequestForm
from app.utils import report
from app.dependencies import validate_admin, get_admin_by_username
from config import LOGIN_WHITE_LIST
from config import LOGIN_NOTIFY_WHITE_LIST

router = APIRouter(tags=['Admin'], prefix='/api')

Expand Down Expand Up @@ -41,7 +41,7 @@ def admin_token(
headers={"WWW-Authenticate": "Bearer"},
)

if client_ip not in LOGIN_WHITE_LIST:
if client_ip not in LOGIN_NOTIFY_WHITE_LIST:
report.login(form_data.username, '🔒', client_ip, True)

return Token(
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
GRPC_USER_AGENT_TEMPLATE = config("GRPC_USER_AGENT_TEMPLATE", default="user_agent/grpc.json")

EXTERNAL_CONFIG = config("EXTERNAL_CONFIG", default="", cast=str)
LOGIN_WHITE_LIST = [ip.strip() for ip in config("LOGIN_WHITE_LIST", default="", cast=str).split(",") if ip.strip()]
LOGIN_NOTIFY_WHITE_LIST = [ip.strip() for ip in config("LOGIN_NOTIFY_WHITE_LIST", default="", cast=str).split(",") if ip.strip()]

USE_CUSTOM_JSON_DEFAULT = config("USE_CUSTOM_JSON_DEFAULT", default=False, cast=bool)
USE_CUSTOM_JSON_FOR_V2RAYN = config("USE_CUSTOM_JSON_FOR_V2RAYN", default=False, cast=bool)
Expand Down

0 comments on commit ae5b6a6

Please sign in to comment.