diff --git a/docker/conf/nginx.conf b/docker/conf/nginx.conf index ae55b85..4b3f8ba 100644 --- a/docker/conf/nginx.conf +++ b/docker/conf/nginx.conf @@ -18,6 +18,7 @@ http { '"$http_user_agent" "$http_x_forwarded_for"'; access_log /log/access.log main; + client_max_body_size 10m; sendfile off; #tcp_nopush on; diff --git a/mitama/__init__.py b/mitama/__init__.py index a85ab2f..ac58a1e 100755 --- a/mitama/__init__.py +++ b/mitama/__init__.py @@ -6,6 +6,8 @@ * 抽象化はするかどうか迷ってる(Pythonで抽象化がどれくらい尊いものかよくわかんない) * argparseを入れようか迷ったけど、位置引数しか必要に成る予定が無いのでとりあえず入れてない """ +import warnings +warnings.simplefilter("ignore") import argparse import mitama.commands diff --git a/mitama/project/commands.py b/mitama/project/commands.py index 5e39568..c63ec1b 100644 --- a/mitama/project/commands.py +++ b/mitama/project/commands.py @@ -3,9 +3,24 @@ import importlib from mitama.app import AppRegistry from mitama.app.http import run_app +from getpass import getpass def run(project, args): port = args.port project.port = port run_app(project, project.port) + +def auth(project, args): + from mitama.models import User + user = args.user + password = args.password + if password == "": + password = getpass("Password:") + try: + user = User.password_auth(user, password) + print(user.get_jwt()) + sys.exit(0) + except Exception: + print("Authentication failed") + sys.exit(1) diff --git a/mitama/project/project.py b/mitama/project/project.py index 3031f7b..abdd579 100644 --- a/mitama/project/project.py +++ b/mitama/project/project.py @@ -80,6 +80,10 @@ def arg_parser(self): cmd_run = subparser.add_parser("run", help="Start serving project") cmd_run.add_argument("-p", "--port", help="serving port", type=int, default=8080) cmd_run.set_defaults(handler=commands.run) + cmd_auth= subparser.add_parser("auth", help="Authenticate user identified by screen name and password") + cmd_auth.add_argument("-u", "--user", help="user's screen name", type=str) + cmd_auth.add_argument("-p", "--password", help="password", type=str, nargs="?", default="", const="") + cmd_auth.set_defaults(handler=commands.auth) #cmd_cleandb = subparser.add_parser("cleandb", help="Clean up unused App's database") #cmd_cleandb.add_argument("prefix", help="") return self._arg_parser diff --git a/poetry.lock b/poetry.lock index e1e12b9..b13d946 100644 --- a/poetry.lock +++ b/poetry.lock @@ -253,14 +253,6 @@ category = "dev" optional = false python-versions = "*" -[[package]] -name = "mysqlclient" -version = "2.0.3" -description = "Python interface to MySQL" -category = "main" -optional = false -python-versions = ">=3.5" - [[package]] name = "pathspec" version = "0.8.1" @@ -277,14 +269,6 @@ category = "main" optional = false python-versions = ">=3.6" -[[package]] -name = "psycopg2" -version = "2.8.6" -description = "psycopg2 - Python-PostgreSQL Database Adapter" -category = "main" -optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" - [[package]] name = "pycodestyle" version = "2.6.0" @@ -560,7 +544,7 @@ testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake [metadata] lock-version = "1.1" python-versions = "^3.6" -content-hash = "7763075ebabc7b773aac9de3530c02983d2cfe7c6d9df5a054262c6367d139ae" +content-hash = "9afc8df25bd6fcfc26a5671fab290535cd6ac570601de555305b3feac4e54766" [metadata.files] appdirs = [ @@ -776,13 +760,6 @@ mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] -mysqlclient = [ - {file = "mysqlclient-2.0.3-cp36-cp36m-win_amd64.whl", hash = "sha256:3381ca1a4f37ff1155fcfde20836b46416d66531add8843f6aa6d968982731c3"}, - {file = "mysqlclient-2.0.3-cp37-cp37m-win_amd64.whl", hash = "sha256:0ac0dd759c4ca02c35a9fedc24bc982cf75171651e8187c2495ec957a87dfff7"}, - {file = "mysqlclient-2.0.3-cp38-cp38-win_amd64.whl", hash = "sha256:71c4b330cf2313bbda0307fc858cc9055e64493ba9bf28454d25cf8b3ee8d7f5"}, - {file = "mysqlclient-2.0.3-cp39-cp39-win_amd64.whl", hash = "sha256:fc575093cf81b6605bed84653e48b277318b880dc9becf42dd47fa11ffd3e2b6"}, - {file = "mysqlclient-2.0.3.tar.gz", hash = "sha256:f6ebea7c008f155baeefe16c56cd3ee6239f7a5a9ae42396c2f1860f08a7c432"}, -] pathspec = [ {file = "pathspec-0.8.1-py2.py3-none-any.whl", hash = "sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d"}, {file = "pathspec-0.8.1.tar.gz", hash = "sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd"}, @@ -821,23 +798,6 @@ pillow = [ {file = "Pillow-8.1.0-pp37-pypy37_pp73-win32.whl", hash = "sha256:b6f00ad5ebe846cc91763b1d0c6d30a8042e02b2316e27b05de04fa6ec831ec5"}, {file = "Pillow-8.1.0.tar.gz", hash = "sha256:887668e792b7edbfb1d3c9d8b5d8c859269a0f0eba4dda562adb95500f60dbba"}, ] -psycopg2 = [ - {file = "psycopg2-2.8.6-cp27-cp27m-win32.whl", hash = "sha256:068115e13c70dc5982dfc00c5d70437fe37c014c808acce119b5448361c03725"}, - {file = "psycopg2-2.8.6-cp27-cp27m-win_amd64.whl", hash = "sha256:d160744652e81c80627a909a0e808f3c6653a40af435744de037e3172cf277f5"}, - {file = "psycopg2-2.8.6-cp34-cp34m-win32.whl", hash = "sha256:b8cae8b2f022efa1f011cc753adb9cbadfa5a184431d09b273fb49b4167561ad"}, - {file = "psycopg2-2.8.6-cp34-cp34m-win_amd64.whl", hash = "sha256:f22ea9b67aea4f4a1718300908a2fb62b3e4276cf00bd829a97ab5894af42ea3"}, - {file = "psycopg2-2.8.6-cp35-cp35m-win32.whl", hash = "sha256:26e7fd115a6db75267b325de0fba089b911a4a12ebd3d0b5e7acb7028bc46821"}, - {file = "psycopg2-2.8.6-cp35-cp35m-win_amd64.whl", hash = "sha256:00195b5f6832dbf2876b8bf77f12bdce648224c89c880719c745b90515233301"}, - {file = "psycopg2-2.8.6-cp36-cp36m-win32.whl", hash = "sha256:a49833abfdede8985ba3f3ec641f771cca215479f41523e99dace96d5b8cce2a"}, - {file = "psycopg2-2.8.6-cp36-cp36m-win_amd64.whl", hash = "sha256:f974c96fca34ae9e4f49839ba6b78addf0346777b46c4da27a7bf54f48d3057d"}, - {file = "psycopg2-2.8.6-cp37-cp37m-win32.whl", hash = "sha256:6a3d9efb6f36f1fe6aa8dbb5af55e067db802502c55a9defa47c5a1dad41df84"}, - {file = "psycopg2-2.8.6-cp37-cp37m-win_amd64.whl", hash = "sha256:56fee7f818d032f802b8eed81ef0c1232b8b42390df189cab9cfa87573fe52c5"}, - {file = "psycopg2-2.8.6-cp38-cp38-win32.whl", hash = "sha256:ad2fe8a37be669082e61fb001c185ffb58867fdbb3e7a6b0b0d2ffe232353a3e"}, - {file = "psycopg2-2.8.6-cp38-cp38-win_amd64.whl", hash = "sha256:56007a226b8e95aa980ada7abdea6b40b75ce62a433bd27cec7a8178d57f4051"}, - {file = "psycopg2-2.8.6-cp39-cp39-win32.whl", hash = "sha256:2c93d4d16933fea5bbacbe1aaf8fa8c1348740b2e50b3735d1b0bf8154cbf0f3"}, - {file = "psycopg2-2.8.6-cp39-cp39-win_amd64.whl", hash = "sha256:d5062ae50b222da28253059880a871dc87e099c25cb68acf613d9d227413d6f7"}, - {file = "psycopg2-2.8.6.tar.gz", hash = "sha256:fb23f6c71107c37fd667cb4ea363ddeb936b348bbd6449278eb92c189699f543"}, -] pycodestyle = [ {file = "pycodestyle-2.6.0-py2.py3-none-any.whl", hash = "sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367"}, {file = "pycodestyle-2.6.0.tar.gz", hash = "sha256:c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e"},