Skip to content

Commit

Permalink
localhost pass through. Now if using from localhost, authentication i…
Browse files Browse the repository at this point in the history
…s not required. This is especially useful in some cases
  • Loading branch information
mpkuse committed Apr 28, 2018
1 parent a4dd008 commit a7d89de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
7 changes: 5 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def authorize_me():
@app.route( "/whoami")
def whoami():
if not github.authorized:
return "<h1>unauthorized</h1>I do not recognize you! You may authorize yourself from /authorize_me"
to_return = "<h1>unauthorized</h1><p>I do not recognize you! You may authorize yourself from /authorize_me</p>"
to_return += '<p>You IP-addr:'+ request.remote_addr +'</p>'
return to_return

to_return = "<h1>authorized</h1>"

Expand All @@ -92,8 +94,9 @@ def whoami():
generated_time = datetime.datetime.now().strftime( "%Y-%m-%d-%H-%M-%s" )
encoded_string = encode( os.environ['GITHUB_CLIENT_SECRET'], '<msg>%s:%s</msg>' %(git_user_name, generated_time) )
to_return += '<p id="GET access coupon">\
You can also authorize yourself by passing the GET parameter `?authorization_token=%s`</p' %(encoded_string)
You can also authorize yourself by passing the GET parameter `?authorization_token=%s`</p>' %(encoded_string)

to_return += '<p>You IP-addr:'+ request.remote_addr +'</p>'

return to_return

Expand Down
4 changes: 4 additions & 0 deletions blue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
def login_required(f):
@wraps(f)
def decorated_function( *args, **kwargs ):
# localhost pass through
if request.remote_addr == '127.0.0.1':
return f(*args, **kwargs )

# Github Authorization check
if not github.authorized:
# GET access token Authorization check
Expand Down
5 changes: 0 additions & 5 deletions run.sh

This file was deleted.

3 changes: 1 addition & 2 deletions run_debug.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export FLASK_APP=site-entry.py
export FLASK_APP=app.py
export FLASK_DEBUG=1

python -m flask run

2 changes: 1 addition & 1 deletion run_gunicorn.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME="site-entry"
NAME="app.py"
NUM_WORKERS=3

gunicorn $NAME:app -b 127.0.0.1:5000 \
Expand Down

0 comments on commit a7d89de

Please sign in to comment.