A bare minimum web service deployment by Greg Brimble.
- Python3.6.3
- pip3
- Clone this repository to wherever you want to deploy.
$ pip3 install virtualenv
- Run
./setup.sh
to build dependencies intovenv
, setgit remote upstream
to point to this repository.
This service can be protected by the following services:
In passenger_wsgi.py
, protect the application by doing the following:
from flask import Flask
from auth.google import GoogleAuthentication
application = Flask(__name__)
my_google_authenticator = GoogleAuthentication(application)
Optionally, in GoogleAuthentication()
, pass in:
whitelist=True
to protect all endpoints by default.domain=gregbrimble.com
for example, to restrict the authenticated Google account domain.
Use the following to protect an endpoint:
@application.route("/secret")
@my_google_authenticator.login_required
def secret():
return "You're authenticated!"
and when using whitelist=True
, the following to make an endpoint exempt from authentication:
@application.route("/")
@my_google_authenticator.login_exempt
def index():
return "Hello, world!"
Sentinel (flask-sentinel)
In passenger_wsgi.py
, protect the application by doing the following:
from flask import Flask
from auth.sentinel import SentinelAuthentication
application = Flask(__name__)
my_sentinel_authenticator = SentinelAuthentication(application)
Just as with GoogleAuthentication()
, optionally pass in whitelist=True
to protect all endpoints by default.
And again, similarly to GoogleAuthentication()
, use the following to protect an endpoint:
@application.route("/secret")
@my_sentinel_authenticator.login_required
def secret():
return "You're authenticated!"
and when using whitelist=True
, the following to make an endpoint exempt from authentication:
@application.route("/")
@my_sentinel_authenticator.login_exempt
def index():
return "Hello, world!"