コード例 #1
0
import process_emails
import processing
import reminders
from processing import ChangeType
from response_models import AlarmType


class FlaskApp(flask.Flask):
    def __init__(self, *args, **kwargs):
        super(FlaskApp, self).__init__(*args, **kwargs)


configuration.initialize()
process_emails.initialize()

basic_auth = fh.HTTPBasicAuth()
token_auth = fh.HTTPTokenAuth()
app = FlaskApp(__name__)
CORS(app,
     supports_credentials=True,
     resources={r'*': {
         'origins': configuration.application_link
     }})
api = fr.Api(app)

# Limit the number of requests that can be made in a certain time period
limiter = fl.Limiter(
    app,
    key_func=fl.util.get_remote_address,
    default_limits=['5 per second', '50 per minute', '1000 per day'])
コード例 #2
0
        server = random.choice(self._conf["queue"])
        return wise_queue.Client(server["hostname"], server["port"])

    def get_subscription_client(self):
        server = random.choice(self._conf["subscription"])
        return wise_sub.Client(server["hostname"], server["port"])


def setup_app():
    app = flask.Flask(__name__)
    app.url_map.strict_slashes = False
    return app


app = setup_app()
auth = flask_httpauth.HTTPBasicAuth()
cl_factory = ServiceClientFactory()


@auth.verify_password
def verify_password(username, password):
    authentication_cl = cl_factory.get_authentication_client()
    try:
        flask.g.account = authentication_cl.sign_in(username=username,
                                                    password=password)
    except Exception:
        flask.g.account = None
    authentication_cl.close()
    return flask.g.account is not None

コード例 #3
0
# -*- coding: utf-8 -*-

import bcrypt

import flask
import flask_httpauth

from tuxedo_mask import services

authentication = flask_httpauth.HTTPBasicAuth()


@authentication.get_password
def get_password(username):

    service = services.TuxedoMaskService.from_configuration()
    application = service.applications.get_by_name('tuxedo_mask')
    user = service.users.get_by_username(username=username,
                                         application=application)

    flask.g.user = user
    flask.g.password_salt = user.password[:29]

    return user.password


@authentication.hash_password
def hash_password(password):

    salt = flask.g.password_salt.encode('utf-8')
    hashed_password = (bcrypt.hashpw(password=password.encode('utf-8'),