parent
efcc4b847d
commit
3117028023
5 changed files with 166 additions and 0 deletions
@ -0,0 +1,105 @@ |
|||||||
|
# Byte-compiled / optimized / DLL files |
||||||
|
__pycache__/ |
||||||
|
*.py[cod] |
||||||
|
*$py.class |
||||||
|
|
||||||
|
# C extensions |
||||||
|
*.so |
||||||
|
|
||||||
|
# Distribution / packaging |
||||||
|
.Python |
||||||
|
build/ |
||||||
|
develop-eggs/ |
||||||
|
dist/ |
||||||
|
downloads/ |
||||||
|
eggs/ |
||||||
|
.eggs/ |
||||||
|
lib/ |
||||||
|
lib64/ |
||||||
|
parts/ |
||||||
|
sdist/ |
||||||
|
var/ |
||||||
|
wheels/ |
||||||
|
*.egg-info/ |
||||||
|
.installed.cfg |
||||||
|
*.egg |
||||||
|
|
||||||
|
# PyInstaller |
||||||
|
# Usually these files are written by a python script from a template |
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it. |
||||||
|
*.manifest |
||||||
|
*.spec |
||||||
|
|
||||||
|
# Installer logs |
||||||
|
pip-log.txt |
||||||
|
pip-delete-this-directory.txt |
||||||
|
|
||||||
|
# Unit test / coverage reports |
||||||
|
htmlcov/ |
||||||
|
.tox/ |
||||||
|
.coverage |
||||||
|
.coverage.* |
||||||
|
.cache |
||||||
|
nosetests.xml |
||||||
|
coverage.xml |
||||||
|
*.cover |
||||||
|
.hypothesis/ |
||||||
|
|
||||||
|
# Translations |
||||||
|
*.mo |
||||||
|
*.pot |
||||||
|
|
||||||
|
# Django stuff: |
||||||
|
*.log |
||||||
|
local_settings.py |
||||||
|
|
||||||
|
# Flask stuff: |
||||||
|
instance/ |
||||||
|
.webassets-cache |
||||||
|
|
||||||
|
# Scrapy stuff: |
||||||
|
.scrapy |
||||||
|
|
||||||
|
# Sphinx documentation |
||||||
|
docs/_build/ |
||||||
|
|
||||||
|
# PyBuilder |
||||||
|
target/ |
||||||
|
|
||||||
|
# Jupyter Notebook |
||||||
|
.ipynb_checkpoints |
||||||
|
|
||||||
|
# pyenv |
||||||
|
.python-version |
||||||
|
|
||||||
|
# celery beat schedule file |
||||||
|
celerybeat-schedule |
||||||
|
|
||||||
|
# SageMath parsed files |
||||||
|
*.sage.py |
||||||
|
|
||||||
|
# Environments |
||||||
|
.env |
||||||
|
.venv |
||||||
|
env/ |
||||||
|
venv/ |
||||||
|
ENV/ |
||||||
|
|
||||||
|
# Spyder project settings |
||||||
|
.spyderproject |
||||||
|
.spyproject |
||||||
|
|
||||||
|
# Rope project settings |
||||||
|
.ropeproject |
||||||
|
|
||||||
|
# mkdocs documentation |
||||||
|
/site |
||||||
|
|
||||||
|
# mypy |
||||||
|
.mypy_cache/ |
||||||
|
|
||||||
|
# Editor |
||||||
|
*.swp |
||||||
|
*.swo |
||||||
|
|
||||||
|
secrets.py |
@ -0,0 +1,5 @@ |
|||||||
|
def create_user(first, last, username, email, password): |
||||||
|
print(first, last, username, email, password) |
||||||
|
|
||||||
|
def set_password(username, password): |
||||||
|
print(username, password) |
@ -0,0 +1,7 @@ |
|||||||
|
Click==7.0 |
||||||
|
Flask==1.1.1 |
||||||
|
gunicorn==20.0.4 |
||||||
|
itsdangerous==1.1.0 |
||||||
|
Jinja2==2.11.1 |
||||||
|
MarkupSafe==1.1.1 |
||||||
|
Werkzeug==0.16.1 |
@ -0,0 +1,7 @@ |
|||||||
|
# LDAP server secrets file, don't commit to version control! |
||||||
|
|
||||||
|
# Auth token, used by Spaceport to authenticate |
||||||
|
# Set this to random characters |
||||||
|
# For example, use the first output of this: |
||||||
|
# head /dev/urandom | sha1sum |
||||||
|
AUTH_TOKEN = '' |
@ -0,0 +1,42 @@ |
|||||||
|
from flask import Flask, abort, request |
||||||
|
app = Flask(__name__) |
||||||
|
|
||||||
|
import ldap |
||||||
|
import secrets |
||||||
|
|
||||||
|
HTTP_UNAUTHORIZED = 401 |
||||||
|
|
||||||
|
def check_auth(): |
||||||
|
auth_header = request.headers.get('Authorization', '') |
||||||
|
if auth_header != 'Token ' + secrets.AUTH_TOKEN: |
||||||
|
abort(HTTP_UNAUTHORIZED) |
||||||
|
|
||||||
|
@app.route('/') |
||||||
|
def index(): |
||||||
|
return '<i>SEE YOU SPACE SAMURAI...</i>' |
||||||
|
|
||||||
|
@app.route('/create-user', methods=['POST']) |
||||||
|
def create_user(): |
||||||
|
check_auth() |
||||||
|
|
||||||
|
first = request.form['first'] |
||||||
|
last = request.form['last'] |
||||||
|
username = request.form['username'] |
||||||
|
email = request.form['email'] |
||||||
|
password = request.form['password'] |
||||||
|
|
||||||
|
ldap.create_user(first, last, username, email, password) |
||||||
|
return '' |
||||||
|
|
||||||
|
@app.route('/set-password', methods=['POST']) |
||||||
|
def set_password(): |
||||||
|
check_auth() |
||||||
|
|
||||||
|
username = request.form['username'] |
||||||
|
password = request.form['password'] |
||||||
|
|
||||||
|
ldap.set_password(username, password) |
||||||
|
return '' |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
app.run(debug=True, host='0.0.0.0') |
Loading…
Reference in new issue