Git Product home page Git Product logo

boilerplate-web-service's Introduction

Boilerplate Web Service

A bare minimum web service deployment by Greg Brimble.

Dependencies

  • Python3.6.3
  • pip3

Setup

  1. Clone this repository to wherever you want to deploy.
  2. $ pip3 install virtualenv
  3. Run ./setup.sh to build dependencies into venv, set git remote upstream to point to this repository.

Features

Authentication

This service can be protected by the following services:

Google

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!"

boilerplate-web-service's People

Contributors

gregbrimble avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.