app: add waitress
This commit is contained in:
parent
686c9efc2c
commit
9f1b765e06
@ -2,6 +2,8 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
|
import waitress
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_pyoidc import OIDCAuthentication
|
from flask_pyoidc import OIDCAuthentication
|
||||||
from flask_pyoidc.provider_configuration import ClientMetadata, ProviderConfiguration
|
from flask_pyoidc.provider_configuration import ClientMetadata, ProviderConfiguration
|
||||||
@ -18,7 +20,6 @@ def _init_oidc(cfg: OidcConfig) -> OIDCAuthentication:
|
|||||||
secret = f.read()
|
secret = f.read()
|
||||||
else:
|
else:
|
||||||
secret = cfg.client_secret
|
secret = cfg.client_secret
|
||||||
print(secret)
|
|
||||||
client = ClientMetadata(client_id=cfg.client_id, client_secret=secret)
|
client = ClientMetadata(client_id=cfg.client_id, client_secret=secret)
|
||||||
|
|
||||||
# Ensure we have the minimum set of scopes for things to work.
|
# Ensure we have the minimum set of scopes for things to work.
|
||||||
@ -49,8 +50,11 @@ def main():
|
|||||||
|
|
||||||
app.register_blueprint(routes.register(auth, "default"))
|
app.register_blueprint(routes.register(auth, "default"))
|
||||||
|
|
||||||
app.config.update({"DEBUG": cfg.app.debug, "SECRET_KEY": secrets.token_hex()})
|
app.config.update({"DEBUG": cfg.core.debug, "SECRET_KEY": secrets.token_hex()})
|
||||||
app.config["user_config"] = cfg
|
app.config["user_config"] = cfg
|
||||||
|
|
||||||
# Reloader doesn't work on NixOS
|
if cfg.core.debug:
|
||||||
|
# Reloader doesn't work on Nix
|
||||||
app.run(use_reloader=False)
|
app.run(use_reloader=False)
|
||||||
|
else:
|
||||||
|
waitress.serve(app, host="127.0.0.1", port=cfg.core.port)
|
||||||
|
@ -14,6 +14,7 @@ class CoreConfig:
|
|||||||
"""Core application configuration."""
|
"""Core application configuration."""
|
||||||
|
|
||||||
debug: bool = False
|
debug: bool = False
|
||||||
|
port: int = 5000
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -42,7 +43,7 @@ class AppConfig:
|
|||||||
class Config:
|
class Config:
|
||||||
"""Top-level configuration."""
|
"""Top-level configuration."""
|
||||||
|
|
||||||
app: CoreConfig
|
core: CoreConfig
|
||||||
oidc: OidcConfig
|
oidc: OidcConfig
|
||||||
apps: Dict[str, AppConfig] = field(default_factory=dict)
|
apps: Dict[str, AppConfig] = field(default_factory=dict)
|
||||||
|
|
||||||
|
18
poetry.lock
generated
18
poetry.lock
generated
@ -420,6 +420,18 @@ brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"]
|
|||||||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "urllib3-secure-extra", "ipaddress"]
|
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "urllib3-secure-extra", "ipaddress"]
|
||||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "waitress"
|
||||||
|
version = "2.1.2"
|
||||||
|
description = "Waitress WSGI server"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7.0"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["Sphinx (>=1.8.1)", "docutils", "pylons-sphinx-themes (>=1.0.9)"]
|
||||||
|
testing = ["pytest", "pytest-cover", "coverage (>=5.0)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "werkzeug"
|
name = "werkzeug"
|
||||||
version = "2.2.2"
|
version = "2.2.2"
|
||||||
@ -449,7 +461,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.9"
|
python-versions = "^3.9"
|
||||||
content-hash = "9f2fbbfe6e41a73d49bc730c9607c1128a6a8d6acee4b362aedddf294b2c6b42"
|
content-hash = "dcd1f67c1a5fd78cb252808867be01588c56361e81086915d82d844f204d6197"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
beaker = [
|
beaker = [
|
||||||
@ -758,6 +770,10 @@ urllib3 = [
|
|||||||
{file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"},
|
{file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"},
|
||||||
{file = "urllib3-1.26.12.tar.gz", hash = "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e"},
|
{file = "urllib3-1.26.12.tar.gz", hash = "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e"},
|
||||||
]
|
]
|
||||||
|
waitress = [
|
||||||
|
{file = "waitress-2.1.2-py3-none-any.whl", hash = "sha256:7500c9625927c8ec60f54377d590f67b30c8e70ef4b8894214ac6e4cad233d2a"},
|
||||||
|
{file = "waitress-2.1.2.tar.gz", hash = "sha256:780a4082c5fbc0fde6a2fcfe5e26e6efc1e8f425730863c04085769781f51eba"},
|
||||||
|
]
|
||||||
werkzeug = [
|
werkzeug = [
|
||||||
{file = "Werkzeug-2.2.2-py3-none-any.whl", hash = "sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5"},
|
{file = "Werkzeug-2.2.2-py3-none-any.whl", hash = "sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5"},
|
||||||
{file = "Werkzeug-2.2.2.tar.gz", hash = "sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f"},
|
{file = "Werkzeug-2.2.2.tar.gz", hash = "sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f"},
|
||||||
|
@ -14,6 +14,7 @@ Flask = "^2.2.2"
|
|||||||
Flask-pyoidc-oda = "^0.6.3"
|
Flask-pyoidc-oda = "^0.6.3"
|
||||||
toml = "^0.10.2"
|
toml = "^0.10.2"
|
||||||
dacite = "^1.6.0"
|
dacite = "^1.6.0"
|
||||||
|
waitress = "^2.1.2"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
black = "^22.8.0"
|
black = "^22.8.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user