forked from usrbinsam/jwt-key-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,561 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
max-line-length = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Flask", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": false, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "/Users/sam/git/mini-key-server/venv/bin/flask", | ||
"cwd": "${workspaceRoot}", | ||
"env": { | ||
"FLASK_APP": "${workspaceRoot}/keyserver.py" | ||
}, | ||
"args": [ | ||
"run", | ||
"--no-debugger", | ||
"--no-reload" | ||
], | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Python", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "${file}", | ||
"cwd": "${workspaceRoot}", | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Attach", | ||
"type": "python", | ||
"request": "attach", | ||
"localRoot": "${workspaceRoot}", | ||
"remoteRoot": "${workspaceRoot}", | ||
"port": 3000, | ||
"secret": "my_secret", | ||
"host": "localhost" | ||
}, | ||
{ | ||
"name": "Python: Terminal (integrated)", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "${file}", | ||
"cwd": "", | ||
"console": "integratedTerminal", | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Terminal (external)", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "${file}", | ||
"cwd": "", | ||
"console": "externalTerminal", | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Django", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "${workspaceRoot}/manage.py", | ||
"cwd": "${workspaceRoot}", | ||
"args": [ | ||
"runserver", | ||
"--noreload", | ||
"--nothreading" | ||
], | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput", | ||
"DjangoDebugging" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Flask (0.11.x or later)", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": false, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter", | ||
"cwd": "${workspaceRoot}", | ||
"env": { | ||
"FLASK_APP": "${workspaceRoot}/quickstart/app.py" | ||
}, | ||
"args": [ | ||
"run", | ||
"--no-debugger", | ||
"--no-reload" | ||
], | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Flask (0.10.x or earlier)", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": false, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "${workspaceRoot}/run.py", | ||
"cwd": "${workspaceRoot}", | ||
"args": [], | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Python: PySpark", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"osx": { | ||
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit" | ||
}, | ||
"windows": { | ||
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd" | ||
}, | ||
"linux": { | ||
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit" | ||
}, | ||
"program": "${file}", | ||
"cwd": "${workspaceRoot}", | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Module", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"module": "module.name", | ||
"cwd": "${workspaceRoot}", | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Pyramid", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"cwd": "${workspaceRoot}", | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"args": [ | ||
"${workspaceRoot}/development.ini" | ||
], | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput", | ||
"Pyramid" | ||
] | ||
}, | ||
{ | ||
"name": "Python: Watson", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config:python.pythonPath}", | ||
"program": "${workspaceRoot}/console.py", | ||
"cwd": "${workspaceRoot}", | ||
"args": [ | ||
"dev", | ||
"runserver", | ||
"--noreload=True" | ||
], | ||
"env": {}, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"python.pythonPath": "${workspaceFolder}/venv/bin/python3.6", | ||
"python.linting.enabled": true, | ||
"python.linting.pylintEnabled": false, | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.mypyEnabled": true, | ||
"python.linting.pydocstyleEnabled": false, | ||
"editor.formatOnSave": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# mini-key-server | ||
|
||
## Requirements | ||
|
||
Aside from the python module requirements listed in [requirements.txt](requirements.txt), the following is required: | ||
* Python 3.6 or later. | ||
* PostgreSQL | ||
|
||
|
||
## Installation | ||
|
||
This software should be used from a [viritualenv](https://virtualenv.pypa.io/en/stable/) environment. | ||
|
||
```sh | ||
virtualenv venv | ||
source venv/bin/activate | ||
pip3 install -U -r requirements.txt | ||
``` | ||
|
||
## Database Setup | ||
|
||
The following commands will create a suitable database for the keyserver to use. | ||
|
||
```sh | ||
su - postgres | ||
createuser keyserver | ||
createdb -O keyserver keyserver | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# MIT License | ||
|
||
# Copyright(c) 2018 Samuel Hoffman | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files(the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
import click | ||
from flask import Flask | ||
from flask_bootstrap import Bootstrap | ||
|
||
from .auth import login_manager, add_user | ||
from .endpoints import api | ||
from .models import db, Event | ||
from .views import frontend | ||
|
||
|
||
def format_event(value): | ||
return Event(value) | ||
|
||
|
||
def create_app(config): | ||
app = Flask(__name__) | ||
|
||
app.config.from_object(__name__) | ||
app.config.from_object("keyserv.config.{}".format(config)) | ||
app.jinja_env.filters["event"] = format_event | ||
|
||
Bootstrap(app) | ||
api.init_app(app) | ||
db.init_app(app) | ||
login_manager.init_app(app) | ||
|
||
app.register_blueprint(frontend) | ||
|
||
@app.cli.command("initdb") | ||
def initdb_command(): | ||
db.create_all() | ||
print("database initialized") | ||
|
||
@app.cli.command("create-user") | ||
@click.argument("username") | ||
@click.argument("password") | ||
def create_user_command(username: str, password: str): | ||
add_user(username, password.encode()) | ||
|
||
return app |
Oops, something went wrong.