Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from flask import Flask
from flask import request
from flask import request, make_response, render_template
import flask

app = Flask(__name__)

Expand All @@ -14,7 +15,34 @@ def issue_token():
def do_stuff():
_headers = request.headers
for h in _headers:
# it's a tuple
if h[0].startswith("Authorization"):
return "You authenticated with {}".format(h)
return "No authentication header was received"
if "this_is_a_bearer_token" in h[1]:
return "Logged in!", 200

else:
return "Unauthenticated, please login again!", 401

return "Unauthenticated, please login again!", 401



# For cookies testing
@app.route('/cookie')
def get_cookie():
response = make_response()
response.set_cookie( "user", "test" )
return response


@app.route('/')
def index():
_headers = request.headers
for h in _headers:
if h[0].startswith("Cookie"):
if "test" in h[1]:
return "Logged in!", 200

else:
return "Unauthenticated, please login again!", 401

return "Unauthenticated, please login again!", 401