-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First release #1
base: main
Are you sure you want to change the base?
Conversation
LICENSE
Outdated
@@ -0,0 +1,21 @@ | |||
MIT License | |||
|
|||
Copyright (c) 2022-2023 Wiren Board |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright (c) 2022-2023 Wiren Board | |
Copyright (c) 2025 Wiren Board |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поменял
self.process_request({"users": delete_user_handler}) | ||
|
||
|
||
def main(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может порт и базу аргументами?
from setuptools import setup | ||
|
||
|
||
def get_version(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
понадежнее бы что-нибудь
предлагаю - или регексп
re.match(r"wb-homeui-auth \((?P<version>.*)\)", "wb-homeui-auth (1.0.0) stable; urgency=medium").group("version")
или вообще - subprocess и дебиан-тулзы
dpkg-parsechangelog --show-field Version
я за регексп
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сделал re, как Вова хотел
wb/homeui_auth/main.py
Outdated
try: | ||
decoded = jwt.decode(cookie, keys_storage.get_key(), algorithms=["HS256"]) | ||
return decoded.get("id") | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
логгировать хотя бы?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Убрал обработку ошибки, теперь это падает в ответ 500 Internal Server Error
wb/homeui_auth/main.py
Outdated
return ["Set-Cookie", f"id={user_id}; HttpOnly; SameSite=Lax;"] | ||
|
||
|
||
def get_cookie_params_dict(params: str) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вроде есть какаят стандартная парсилка куков
https://stackoverflow.com/questions/32281041/converting-cookie-string-into-python-dict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я знаю, но раньше это всё запускалось отдельным скриптом через fcgiwrap, не хотел тащить зависимости, чтоб время загрузки скрипта уменьшить. Сейчас не важно, переделал на SimpleCookie
keys_storage: KeysStorage = None | ||
|
||
|
||
def get_required_user_type(request: BaseHTTPRequestHandler) -> UserType: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мб return UserType(request.headers.get("Required-User-Type", UserType.ADMIN)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я хотел, чтоб при неправильном типе пользователя тоже был админ, но чё-то сейчас подумал, что не надо. Пусть лучше будет 500 Internal Server Error
length = int(request.headers.get("Content-Length")) | ||
form = json.loads(request.rfile.read(length).decode("utf-8")) | ||
validate_login_request(form) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
логи?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все ответы, которые не 200, идут через http.server.send_error, который по умолчанию в лог падает
USER = "user" | ||
|
||
@dataclass | ||
class User: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
как идея: можно здесь сделать все None по дефолту и убрать кучу проверок на is None выше
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тогда надо проверять содержимое User
. Не, не хочу
Сервис аутентификации и управления пользователями для Homeui