Example #1
0
app.config.from_envvar("ALERTA_SVR_CONF_FILE", silent=True)

if "DEBUG" in os.environ:
    app.debug = True

if "BASE_URL" in os.environ:
    app.config["BASE_URL"] = os.environ["BASE_URL"]

if "SECRET_KEY" in os.environ:
    app.config["SECRET_KEY"] = os.environ["SECRET_KEY"]

if "AUTH_REQUIRED" in os.environ:
    app.config["AUTH_REQUIRED"] = True if os.environ["AUTH_REQUIRED"] == "True" else False

if "ADMIN_USERS" in os.environ:
    app.config["ADMIN_USERS"] = os.environ["ADMIN_USERS"].split(",")

if "CUSTOMER_VIEWS" in os.environ:
    app.config["CUSTOMER_VIEWS"] = True if os.environ["CUSTOMER_VIEWS"] == "True" else False

if "OAUTH2_CLIENT_ID" in os.environ:
    app.config["OAUTH2_CLIENT_ID"] = os.environ["OAUTH2_CLIENT_ID"]

if "OAUTH2_CLIENT_SECRET" in os.environ:
    app.config["OAUTH2_CLIENT_SECRET"] = os.environ["OAUTH2_CLIENT_SECRET"]

if "ALLOWED_EMAIL_DOMAINS" in os.environ:
    app.config["ALLOWED_EMAIL_DOMAINS"] = os.environ["ALLOWED_EMAIL_DOMAINS"].split(",")

if "ALLOWED_GITHUB_ORGS" in os.environ:
    app.config["ALLOWED_GITHUB_ORGS"] = os.environ["ALLOWED_GITHUB_ORGS"].split(",")
Example #2
0
from flask.ext.script import Manager, Shell
from flask.ext.bootstrap import Bootstrap
from flask.ext.wtf import Form
from wtforms import StringField, SubmitField, IntegerField
from wtforms.validators import Required
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.httpauth import HTTPBasicAuth, HTTPDigestAuth

basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)
app.config["SECRET_KEY"] = "reggie_magic_key"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, "data.sqlite")
app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = True
app.config["ADMIN_USERS"] = {"admin": "not_verybig_secret"}


manager = Manager(app)
bootstrap = Bootstrap(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
httpauth = HTTPDigestAuth()


@httpauth.get_password
def get_pw(username):
    if username in app.config["ADMIN_USERS"]:
        return app.config["ADMIN_USERS"].get(username)
    return None