Example #1
0
def create_app():
  options = {
    'port' : 0,
    'unitTesting': False
  }
  WebConfig.config(options)

  b = Borg()
  app = Flask(__name__)
  app.config['DEBUG'] = True
  app.config['SECRET_KEY'] = b.secretKey
  app.config['SECURITY_PASSWORD_HASH'] = b.passwordHash
  app.config['SECURITY_PASSWORD_SALT'] = b.passwordSalt
  app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://' + b.auth_dbUser + ':' + b.auth_dbPasswd + '@' + b.auth_dbHost + '/' + b.auth_dbName
  b.logger.setLevel(b.logLevel)
  b.logger.debug('Error handlers: {0}'.format(app.error_handler_spec))
  app.secret_key = os.urandom(24)
  logger = logging.getLogger('werkzeug')
  logger.setLevel(b.logLevel)
  enable_debug = b.logLevel = logging.DEBUG

  cors = CORS(app)
  db.init_app(app)
  user_datastore = SQLAlchemyUserDatastore(db,User, Role)
  security = Security(app, user_datastore)

  from main import main as main_blueprint 
  app.register_blueprint(main_blueprint)

  with app.app_context():
    db.create_all()

  return app
Example #2
0
app.config['FLASK_LOG_LEVEL'] = 'INFO'
flask_log = Logging(app)
app.logger.debug('Testing a debug message')
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'zijdle,t7ie1'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///rsdb.db'
app.config['SECURITY_URL_PREFIX'] = "/bck"
app.config['MAIL_SERVER'] = 'smtp.obs-nancay.fr'
#app.config['CONFIRMABLE'] = True
#app.config['REGISTERABLE'] = True
app.config['SECURITY_EMAIL_SENDER'] = 'admin@ambari-rsdb.obs-nancay.fr'
app.config['SECURITY_RECOVERABLE'] = True
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_CONFIRMABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] ='sha256_crypt'
app.config['SECURITY_PASSWORD_SALT'] = 'encore'
app.config['SECURITY_UNAUTHORIZED_VIEW'] = 'bck/login'
#app.config['SECURITY_CONFIRM_URL' ] = '/../confirm'
#app.config['SECURITY_LOGIN_URL'] = '/bck/login'
#app.config['SECURITY_LOGOUT_URL'] ='/bck/logout'
#app.config['SECURITY_REGISTER_URL'] ='/bck/register'
#app.config['SECURITY_RESET_URL'] ='/bck/reset'
#app.config['SECURITY_CHANGE_URL'] ='/bck/change'

#app.config['SECURITY_POST_LOGIN_VIEW'] ='/bck/'
#app.config['SECURITY_POST_LOGOUT_VIEW'] ='/bck/'
#app.config['MAIL_PORT'] = 465
#app.config['MAIL_USE_SSL'] = True
#app.config['MAIL_USERNAME'] = 'username'
#app.config['MAIL_PASSWORD'] = 'password'
mail = Mail(app)
app.config['MAIL_USERNAME'] = dotenv.get(
    'KNOTMARKER_MAIL_USERNAME', 'knotmarker@gmail.com')
app.config['MAIL_PASSWORD'] = dotenv.get('KNOTMARKER_MAIL_PASSWORD')

mail = Mail(app)

app.config['MONGODB_DB'] = dotenv.get('KNOTMARKER_MONGODB_DB', 'knotmarker')
app.config['MONGODB_HOST'] = dotenv.get('KNOTMARKER_MONGODB_HOST', 'localhost')
app.config['MONGODB_PORT'] = dotenv.get('KNOTMARKER_MONGODB_PORT', 27017)
app.config["SECRET_KEY"] = bytes(dotenv.get('KNOTMARKER_SECRET_KEY'), 'utf8')
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_CONFIRMABLE"] = True
app.config["SECURITY_RECOVERABLE"] = True
app.config["SECURITY_CHANGEABLE"] = True
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
app.config['SECURITY_PASSWORD_SALT'] = bytes(dotenv.get('KNOTMARKER_PASSWORD_SALT'), 'utf8')

SENTRY_DSN = dotenv.get('KNOTMARKER_SENTRY_DSN', None)

if SENTRY_DSN:
    from raven.contrib.flask import Sentry
    app.config['SENTRY_USER_ATTRS'] = ['email']
    sentry = Sentry(app, logging=True, level=logging.ERROR, dsn=SENTRY_DSN)
else:
    sentry = None


@app.context_processor
def inject_sentry():
    if sentry:
        return {
Example #4
0
app = Flask(__name__,template_folder=template_folder,static_folder=static_folder)

app.app_context().push()

app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
app.config["MONGODB_HOST"] = MONGODB_HOST
app.config['MONGODB_DB'] = MONGODB_DB
app.config['MONGODB_PORT'] = MONGODB_PORT


"""
The following section sets the overall configuration for flask-security
"""
app.config['SECURITY_PASSWORD_HASH'] = SECURITY_PASSWORD_HASH
app.config['SECURITY_PASSWORD_SALT'] = SECURITY_PASSWORD_SALT
app.config['SECURITY_CONFIRM_SALT'] = SECURITY_CONFIRM_SALT
app.config['SECURITY_RESET_SALT'] = SECURITY_RESET_SALT
app.config['SECURITY_CONFIRMABLE'] = True
app.config['SECURITY_RECOVERABLE'] = True
app.config['SECURITY_CHANGEABLE']  = SECURITY_CHANGEABLE


"""
The default settings for Mail
"""
app.config['MAIL_SERVER'] = MAIL_SERVER
app.config['MAIL_PORT'] = MAIL_PORT
app.config['MAIL_USE_TLS'] = MAIL_USE_TLS
app.config['MAIL_USERNAME'] = MAIL_USERNAME
app.config['MAIL_PASSWORD'] =MAIL_PASSWORD
Example #5
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from db.db_config import SQLALCHEMY_DATABASE_URI

app_webSite = Flask(__name__)
app_webSite.config['DEBUG'] = True

app_webSite.config['SECRET_KEY'] = 'super-secret'

#account creation
app_webSite.config['SECURITY_REGISTERABLE'] = True
app_webSite.config['SECURITY_CONFIRMABLE'] = True
app_webSite.config['SECURITY_SEND_REGISTER_EMAIL'] = False
#password hash
app_webSite.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
app_webSite.config['SECURITY_PASSWORD_SALT'] = 'this is some random salt :)'

#db
app_webSite.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI

# DB configuration.
db = SQLAlchemy(app_webSite)


Example #6
0
from flask.ext.security.signals import user_registered

from ml.utils import parse_data
from ml.mltask import MLTask
from ml.algorithms import METHOD_NAMES, TYPE_NAMES

###############################################################################
# Config
###############################################################################
app = Flask(__name__)
app.config.from_object(__name__)
app.config['DEBUG'] = 'PRODUCTION' not in os.environ
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'development_key')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('SQL_DATABASE_URI', 'sqlite:///dev.db')
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = os.environ.get('PASSWORD_SALT', '$2a$12$skCRnkqE5L01bHEke678Ju')

app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_REGISTER_URL'] = '/register'
app.config['SECURITY_REGISTER_USER_TEMPLATE'] = 'register.html'
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False

app.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'login.html'
app.config['SECURITY_LOGIN_URL'] = '/login'
app.config['SECURITY_CHANGEABLE'] = True

app.config['UPLOAD_FOLDER'] = 'uploads'

app.jinja_env.filters['js'] = lambda v: Markup(json.dumps(v))

# Fake emails for now
Example #7
0

app = Flask(__name__)

app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)

app.config['MONGODB_SETTINGS'] = {
    'db': 'motoparking',
    'host': 'mongodb://localhost:27017/motoparking'
}
app.config['DEBUG'] = True

app.config['SECRET_KEY'] = 'super-secret'
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
app.config['SECURITY_PASSWORD_SALT'] = 'ytdjf.jk,upo8etsgdf,asdf34ttgewgq3g[q[epqogqjg;'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_MSG_LOGIN'] = (u'Вы не авторизованы или Вас нет в списках доступа.', 'info')

if os.environ.get('MONGODB_DB'):
    app.config['MONGODB_SETTINGS'] = {
        'db': os.environ.get('MONGODB_DB'),
        'host': os.environ.get('PROD_MONGODB')
    }
    app.config['DEBUG'] = False
    app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
    app.config['SECURITY_PASSWORD_SALT'] = os.environ.get('SECURITY_PASSWORD_SALT')

# app.config['SECURITY_LOGIN_USER_TEMPLATE'] = "login.html"

# app.config['SOCIAL_FACEBOOK'] = {
Example #8
0
from flask.ext.mail import Mail
from boto.ec2 import connect_to_region
from boto.s3.connection import S3Connection
from boto.s3.key import Key
from urllib2 import urlopen
from datetime import datetime
import json, os, random, string, subprocess

app = Flask(__name__)
app.config['DEBUG'] = False 
app.config['SECRET_KEY'] = "afsdjfsafasd239"
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://ctf:fishandchipsaredelicious@localhost/ctf'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_CONFIRMABLE'] = False
app.config['SECURITY_PASSWORD_HASH'] = 'plaintext'
app.config['SECURITY_PASSWORD_SALT'] = 'DFa#reJK84rijhAiojOIHGFKLAJR8U'
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'casectf@gmail.com'
app.config['MAIL_PASSWORD'] = 'correcthorsebatterystaple'
BUCKET_NAME = 'case_ctf_spring_2013'
SECRET_KEY = 'LgGsOQJr27ZRiBeeuRx/kSBf6fV8Qs7wH1o/djA7'
ACCESS_KEY = 'AKIAJGM53Z656332A33A'
ec2 = connect_to_region('us-east-1', aws_access_key_id = ACCESS_KEY,
        aws_secret_access_key = SECRET_KEY)
startup_script = "#! /bin/bash"

mail = Mail(app)
db = SQLAlchemy(app)
session = db.session
Example #9
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin, login_required
from flask_cors import CORS
from cairis.core.Borg import Borg
import cairis.core.BorgFactory

__author__ = 'Shamal Faily'

cairis.core.BorgFactory.dInitialise()
app = Flask(__name__)
app.config['DEBUG'] = True
b = Borg()
app.config['SECRET_KEY'] = b.secretKey
app.config['SECURITY_PASSWORD_HASH'] = b.passwordHash
app.config['SECURITY_PASSWORD_SALT'] = b.passwordSalt
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://' + b.auth_dbUser + ':' + b.auth_dbPasswd + '@' + b.auth_dbHost + '/' + b.auth_dbName

db = SQLAlchemy(app)
cors = CORS(app)

roles_users = db.Table('roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('auth_user.id')), db.Column('role_id', db.Integer(), db.ForeignKey('auth_role.id')))

class Role(db.Model, RoleMixin):
  __tablename__ = 'auth_role'
  id = db.Column(db.Integer(), primary_key=True)
  name = db.Column(db.String(80), unique=True)
  description = db.Column(db.String(255))

class User(db.Model, UserMixin):
  __tablename__ = 'auth_user'
configer = Configer()
SECURITY = 'Security'

logging.basicConfig(filename = 'app.log', level = logging.INFO)
logging.info('name: %s' % __name__)
app = Flask(__name__)

app.config['SECRET_KEY'] = configer.configOptionValue(SECURITY, 'app_secret')
basedir = os.path.abspath(os.path.dirname(__file__))
dbName = 'db.sqlite'
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, dbName)
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir,
                                                                    dbName)
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
app.config['SECURITY_PASSWORD_SALT'] = configer.configOptionValue(SECURITY,
                                                                  'app_salt')
app.config['SECURITY_POST_LOGIN'] = '/profile'

# Extensions.
db = SQLAlchemy(app)

CONFIG = {'google': {'class_': oauth2.Google,
                     'consumer_key': configer.configOptionValue(SECURITY,
                                                                'google_consumer_key'),
                     'consumer_secret': configer.configOptionValue(SECURITY,
                                                                   'google_consumer_secret'),
                     'scope': oauth2.Google.user_info_scope + [
                         'https://www.googleapis.com/auth/userinfo.profile'], }, }

authomatic = Authomatic(CONFIG, configer.configOptionValue(SECURITY,
                                                           'authomatic_secret'))
Example #11
0
File: api.py Project: schvin/wharf
r = redis.StrictRedis(host=REDIS_HOST, port=int(REDIS_PORT))
c = client.Client(version="1.6", base_url='http://%s:4243' % DOCKER_HOST)

app = Flask(__name__)
app.config['DEBUG'] = True
# this should be re-generated for production use
app.config['SECRET_KEY'] = 'EckNi2Fluincawd+'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/db.sqlite'
app.config['DEFAULT_MAIL_SENDER'] = 'dockerwharf@gmail.com'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_CONFIRMABLE'] = True
app.config['SECURITY_CHANGEABLE'] = True
app.config['SECURITY_RECOVERABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
# this should be re-generated for production use
app.config['SECURITY_PASSWORD_SALT'] = 'S)1<P3_~$XF}DI=#'
app.config['SECURITY_POST_REGISTER_VIEW'] = '/login'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['SERVICES_FOLDER'] = SERVICES_FOLDER
app.config.from_object('config.email')
app.debug = True

# Setup mail extension
mail = Mail(app)

# Setup babel
babel = Babel(app)

# Create database connection object
db = SQLAlchemy(app)
Example #12
0
from peewee import *
from flask.ext.security import Security, PeeweeUserDatastore, \
    UserMixin, RoleMixin, login_required

app = Flask(__name__)

################################    CONFIGGY PUDDING    ################################

app.config['DATABASE'] = {
    'name': 'example.db',
    'engine': 'peewee.SqliteDatabase',
}
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = 'somelongrandomhashythingright??'
app.config['SECURITY_REGISTER_URL'] = '/signmeup'
app.config['SECURITY_POST_LOGIN_VIEW'] = '/pamps'
app.config['SECURITY_POST_LOGOUT_VIEW'] = '/aligator'
app.config['SECURITY_POST_REGISTER_VIEW'] = '/pamps'
app.config['SECURITY_UNAUTHORIZED_VIEW'] = '/neeeoooope'

########################################################################################

RDB_HOST = 'localhost'
RDB_PORT = 28015
RDB_DB = 'pample'

cors = CORS(app)

##################################    USERDATASTORE    ##################################
from flask import Flask, render_template, request
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.security import Security, SQLAlchemyUserDatastore, \
    UserMixin, RoleMixin, login_required, logout_user, roles_accepted

app = Flask(__name__)
app.config['DEBUG'] = True
# Configure Flask-SQLAlchemy - sqlite
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///item.db'
# Secret key used for the session key
app.config['SECRET_KEY'] = 'super-secret'

app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = 'super-secret'
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False
app.config['SECURITY_POST_REGISTER_VIEW'] = '/'
app.config['SECURITY_UNAUTHORIZED_VIEW'] = '/error'
db = SQLAlchemy(app)

# Define models
roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
        db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))


class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))
Example #14
0
    if 'postgres' in conf.SQLALCHEMY_DATABASE_URI:
        application.config['SQLALCHEMY_POOL_SIZE'] = 15
        application.config['SQLALCHEMY_MAX_OVERFLOW'] = 0

scheme, domain, _, _, _ = urlsplit(conf.PLATFORM_URL)
application.config['SERVER_NAME'] = domain
application.config['PREFERRED_URL_SCHEME'] = scheme

set_logging(conf.LOG_PATH, log_level=conf.LOG_LEVEL)

# Create secrey key so we can use sessions
application.config['SECRET_KEY'] = getattr(conf, 'WEBSERVER_SECRET', None)
if not application.config['SECRET_KEY']:
    application.config['SECRET_KEY'] = os.urandom(12)

application.config['SECURITY_PASSWORD_SALT'] = getattr(conf,
                                                'SECURITY_PASSWORD_SALT', None)
if not application.config['SECURITY_PASSWORD_SALT']:
    application.config['SECURITY_PASSWORD_SALT'] = os.urandom(12)

db = SQLAlchemy(application)

# Create the Flask-Restless API manager.
manager = flask_restless.APIManager(application, flask_sqlalchemy_db=db)


def populate_g():
    from flask import g
    g.db = db
    g.app = application
Example #15
0
from flask import Flask, request, render_template, flash, redirect, url_for, Markup
from flask.ext.pymongo import PyMongo
from flask_wtf.csrf import CsrfProtect
from forms import URLForm
import string
import random

app = Flask(__name__)
app.config['MONGO_DBNAME'] = 'links'

#some basic security, used random passwords instead of a more secure one for this example
app.config['SECRET_KEY'] = '!xsmkOZDGs\1EKgsO5eR1<OHO*lNFz'
app.config['SECURITY_PASSWORD_SALT'] = ')2 .D~756R:G^0v2yOx\$>SDpN/\dN'

mongo = PyMongo(app)
CsrfProtect(app)

@app.route('/', methods=('GET',))
def homepage():
	form = URLForm()
	return render_template('index.html', form=form)

@app.route('/create-url', methods=('POST',))
def create():
	form = URLForm()
	if request.method =='POST':
		if form.validate():
			try:
				#check if site in database, if not create a new document
				site_id = mongo.db.links.find_one_or_404({'url':form.url.data})['site_id']
			except:
        return resp
    else:
        flash("You are now logged in as %s. Login as a different user to delete this account." % login_session['username'])
        resp = redirect(url_for('user_administraion', user= login_session['user_id']))
        return resp

@app.route('/api/')
def api():
    resp = redirect(url_for('api_docs.html'))
    return resp


@app.errorhandler(404)
def not_found(error):
    resp = make_response(render_template('not_found.html'))
    return resp

if __name__ == '__main__':
    client_secret = "7waNwWUO1iMUsSQZC5fl-2F8"
    app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
    #app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 ** 2
    app.secret_key = '\x86\x80\xa9\x1c\xff\x9c\xb4\xd4\xd8\x98\x16!n]\xe4\x8eW\x17t\xa8U\xeee\xef'
    SECRET_KEY = '\x86\x80\xa9\x1c\xff\x9c\xb4\xd4\xd8\x98\x16!n]\xe4\x8eW\x17t\xa8U\xeee\xef'
    app.config['SECURITY_PASSWORD_SALT']= 'bqJbw1eJRHZC5hm3'
    app.debug = True
    context = ('ssl.cert', 'ssl.key')
    app.run()#host='127.0.0.1', port=8080)#, ssl_context=context, threaded=True)
    

# set the secret key.  keep this really secret:
import logging, os
from flask import Flask
from flask_mail import Mail
logger = logging.getLogger('python')
logger.setLevel(logging.WARNING)
mail = Mail()
app = Flask(__name__)
app.config.from_object('config.{}Config'.format(os.environ.get('SERVER_ENV', 'Development')))
app.config['SQLALCHEMY_DATABASE_URI'] = app.config['SQLALCHEMY_DATABASE_URI'].format(
	os.environ.get('DB_USER'),
	os.environ.get('DB_PASS'),
	os.environ.get('DB_HOST'),
	os.environ.get('DB_NAME')
	)
app.config['APP_NAME'] = app.config['APP_NAME'].format(os.environ.get('NAME', 'API'))
app.config['SECRET_KEY'] = app.config['SECRET_KEY'].format(os.environ.get('SECRET_KEY', 'SECRET'))
app.config['SECURITY_PASSWORD_SALT'] = app.config['SECURITY_PASSWORD_SALT'].format(os.environ.get('SECURITY_PASSWORD_SALT'))
Example #18
0
from shelf import Shelf
from shelf.base import db
from shelf.plugins.library import FileAdmin
from shelf.security.models import User, Role

import admin
import model

app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///blog.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SECRET_KEY'] = 'notasecret'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = 'mysalt'#"hash_123678*",
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False

app.config['APP_ROOT'] = os.path.dirname(os.path.abspath(__file__))
app.config['APP_STATIC'] = os.path.join(app.config['APP_ROOT'], 'static')
app.config['MEDIA_ROOT'] = os.path.join(app.config['APP_STATIC'], 'media')
app.config['MEDIA_URL'] = '/static/media/'

try:
    os.makedirs(app.config['MEDIA_ROOT'])
except OSError:
    pass

with app.app_context():
    db.init_app(app)
    db.app = app
Example #19
0
from flask.ext.assets import Environment, Bundle
from flask.ext.mongoengine import MongoEngine

from momentjs import momentjs

import re
from jinja2 import evalcontextfilter, Markup, escape


app = Flask(__name__)
app.config['MONGO_URI'] = os.getenv('MONGOHQ_URI', 'mongodb://dev:dev@localhost/federation')
app.config['MONGODB_SETTINGS'] = {'db': 'federation', 'host': app.config['MONGO_URI']}
app.config['FACEBOOK_AUTH'] = os.getenv('FACEBOOK_AUTH')

app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = os.getenv('SECURITY_PASSWORD_SALT', '')
app.config['SECURITY_CHANGEABLE'] = True
app.config['SECURITY_TRACKABLE'] = True

app.secret_key = os.getenv('SECRET_KEY', '')

app.jinja_env.globals['momentjs'] = momentjs
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True


# Add a LaTex env for Jinja2

LATEX_SUBS = (
    (re.compile(r'\\'), r'\\textbackslash'),
    (re.compile(r'([{}_#%&$])'), r'\\\1'),
Example #20
0
import os

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate
from flask.ext.bcrypt import Bcrypt
from flask.ext.security import Security, SQLAlchemyUserDatastore

from config import basedir

app = Flask(__name__)
app.config.from_object('config')
app.config['SECURITY_REGISTERABLE'] = True
#TODO - make proper confirmation email
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False

db = SQLAlchemy(app)
migrate = Migrate(app, db)
# bcrypt = Bcrypt(app)
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = 'bcrypt'

from roadtrip.models import User, Role
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
security = Security(app, user_datastore)

from roadtrip import views, models
Example #21
0
app.config['APP_LOG'] = 'minecontrol.log'
app.config['AWS_REGION'] ="us-west-2" 

# celery config
app.config['CELERY_BROKER_URL']='redis://localhost:6379'
app.config['CELERY_RESULT_BACKEND']='redis://localhost:6379'
app.config['CELERY_TASK_SERIALIZER'] = 'json'
app.config['CELERY_RESULT_SERIALIZER'] = 'json'
app.config['CELERY_ACCEPT_CONTENT'] = ['json']

app.config['SECURITY_CHANGEABLE'] = True
app.config['SECURITY_SEND_PASSWORD_CHANGE_EMAIL'] = False
# enable hashed passwords
app.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
# remember to override SECURITY_PASSWORD_SALT
app.config['SECURITY_PASSWORD_SALT'] = '2FZcxCHezFY2j0QVC6sq'

app.config['DEFAULT_ADMIN_PASS'] = 'changeme'
app.config['SERVER_EMAIL_ADDRESS'] = 'minecontrol@minecontrol.us'
app.config['ADMINS'] = []

# load local configuration
app.config.from_pyfile('../my.cfg', silent=True)

# For AWS Control ~/.boto or /etc/boto.cfg must exist.
# see https://aws.amazon.com/articles/Python/3998

if not app.debug:
    import logging
    from logging.handlers import RotatingFileHandler 

###########################################################################
# Configuration
###########################################################################

app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'super-secret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///databases/security.db'
app.config['SQLALCHEMY_BINDS'] = {
    'security':        'sqlite:///databases/security.db',
    'application':     'sqlite:///databases/application.db'
}
app.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
app.config['SECURITY_PASSWORD_SALT'] = '9yAPe05Nsjl6UjJEMlXOTsiuyPlcvfr9n26OLVuCReIs3Pw3SGnHv39'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_CHANGABLE'] = True
app.config['SECURITY_RECOVERABLE'] = True
app.config['SECURITY_CONFIRMABLE'] = False


# Mail
mail = Mail()
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 587
app.config["MAIL_USE_SSL"] = False
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USERNAME"] = 'user@gmail.com'
app.config["MAIL_PASSWORD"] = '*****'
mail.init_app(app)
Example #23
0
from wtforms import Form, IntegerField, TextField, TextAreaField, validators
from flask_security import login_required, http_auth_required, auth_token_required, \
     Security, RoleMixin, UserMixin, SQLAlchemyUserDatastore
from flask_sqlalchemy import SQLAlchemy


# create our little application :)
app = Flask(__name__)

app.config['DEBUG'] = True
app.config['USERNAME'] = 'admin'
app.config['PASSWORD'] = 'default'
app.secret_key = 'super secret key'
app.config['SECURITY_TRACKABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
app.config['SECURITY_PASSWORD_SALT'] = 'something_super_secret_change_in_production'
app.config['WTF_CSRF_ENABLED'] = False
app.config['SECURITY_TOKEN_MAX_AGE'] = 365*24*60*60*1000

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sqlite2.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

# import settings from settings file
#app.config.from_envvar('LATERSEND_SETTINGS', silent=True)

app.config.from_object(__name__)

# Create database connection object
db = SQLAlchemy(app)

Example #24
0
from flask import Flask, render_template, request
from flask_peewee.db import Database
from peewee import *
from flask_restful import Resource, Api
from flask_security import Security, PeeweeUserDatastore, \
    UserMixin, RoleMixin, login_required, auth_token_required, current_user
from bson import json_util
import json

# Create app
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'super-secret'
app.config['SECURITY_PASSWORD_SALT'] = '12345678'
app.config['WTF_CSRF_ENABLED'] = False
app.config['SECURITY_REGISTERABLE'] = True
app.config['DATABASE'] = {
    'name': 'examplpe.db',
    'engine': 'peewee.SqliteDatabase',
}


# Create Api
api = Api(app)

# Create database conection object
db = Database(app)

class Role(db.Model, RoleMixin):
    name = CharField(unique=True)
    description = TextField(null=True)
Example #25
0

app.config['DEBUG'] = False
app.config['TOKEN'] = settings.TOKEN
app.config['SQLALCHEMY_DATABASE_URI'] = db_str
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SQLALCHEMY_BINDS'] = db_binds
app.config['SECRET_KEY'] = settings.SECURITY_SECRET

app.config['SECURITY_LOGIN_URL'] = '/security/login'
app.config['SECURITY_LOGOUT_URL'] = '/security/logout'
app.config['SECURITY_REGISTER_URL'] = '/security/register'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False
app.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
app.config['SECURITY_PASSWORD_SALT'] = settings.SECURITY_SECRET
app.config['SECURITY_LOGIN_USER_TEMPLATE'] = '/security/login.html'
app.config['SECURITY_REGISTER_USER_TEMPLATE'] = '/security/register.html'
app.config['SECURITY_POST_REGISTER_VIEW'] = '/admin'

db = SQLAlchemy(app)


cache = RedisCache(
    host=settings.REDIS_HOST,
    port=settings.REDIS_PORT,
    db=settings.REDIS_DB,
    password=settings.REDIS_PASSWORD,
    key_prefix='wechat')

from wechat_admin.base.views import base
Example #26
0
from flask import Flask
app = Flask(__name__)


############### Load config #################
app.config['SECRET_KEY'] = "hello world"
app.config['DATABASE_FILE'] = "/tmp/database.db"
app.config['TMP_PICTURE_FOLDER'] = "/tmp/liotyphserver_tmp/"

app.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
app.config['SECURITY_PASSWORD_SALT'] = 'fhasdgihwntlgy8f'


import liotyphserver.model
import liotyphserver.views
Example #27
0
import redis
from config import apiconf, REDIS_CONF, stripeconf

sys.path.append('../')

from models import *
from queue import *


PRAXYK_API_APP = Flask(__name__) # our main flask app object
PRAXYK_API_APP.config.from_object('api.config') # our main flask app object configured from 'config.py'

# security and auth default args
PRAXYK_API_APP.config['SECURITY_TOKEN_AUTHENTICATION_KEY'] = 'token'
PRAXYK_API_APP.config['SECURITY_PASSWORD_HASH'] = apiconf['security_password_hash']
PRAXYK_API_APP.config['SECURITY_PASSWORD_SALT'] = apiconf['security_password_salt']
PRAXYK_API_APP.config['WTF_CSRF_ENABLED'] = False

INITIAL_USERS = apiconf['users'] # list of initial users (root, admins, etc) to add to database upon creation

api = Api(PRAXYK_API_APP)        # our flask.restful api object that we use for routing
db = SQLAlchemy(PRAXYK_API_APP)  # this is our handle to the database
bcrypt = Bcrypt(PRAXYK_API_APP)  # used for password hashing
CORS(PRAXYK_API_APP)             # cross-site scripting
# RQ(PRAXYK_API_APP)               # redis queue

BASE_URL           = "localhost"
VERSION            = "/v1"

# routes
LOGIN_ROUTE        = VERSION + "/login/"
import os
from flask import Flask
from flask.ext.login import LoginManager
from flask.ext.openid import OpenID
from flask.ext.sqlalchemy import SQLAlchemy

UPLOAD_FOLDER = "app/static/filefolder"
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['SECRET_KEY'] = 'key'
app.config['SECURITY_PASSWORD_SALT'] = 'my_precious_two'
from flask.ext.marshmallow import Marshmallow
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://avogzdlajafwwd:pzWChTjmvTtZJ6W2PCQg8tSXsE@ec2-107-20-234-127.compute-1.amazonaws.com:5432/d267het21etqvv'
db = SQLAlchemy(app)
lm = LoginManager()
lm.init_app(app)
oid = OpenID(app, '/tmp')


from app import views, models
Example #29
0
    connect(
        MONGO_URL.split("/")[-1],
        host=MONGO_URL,
        port=1043,
        username=username,
        password=password
    )
else:
    app.config['MONGODB_DB'] = os.environ['DB_NAME']
    app.config['MONGODB_HOST'] = os.environ['DB_HOST']
    app.config['MONGODB_PORT'] = os.environ['DB_PORT']  # 27017

app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False
app.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
app.config['SECURITY_PASSWORD_SALT'] = os.environ['SALT']

db = MongoEngine(app)

class Role(db.Document, RoleMixin):
    name = db.StringField(max_length=80, unique=True)
    description = db.StringField(max_length=255)

class User(db.Document, UserMixin):
    email = db.StringField(max_length=255)
    password = db.StringField(max_length=255)
    active = db.BooleanField(default=True)
    confirmed_at = db.DateTimeField()
    roles = db.ListField(db.ReferenceField(Role), default=[])
    
class Log(db.Document):
from flask import Flask
import os
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object(__name__)
app.config['DEBUG'] = 'PRODUCTION' not in os.environ
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'development_key')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('SQL_DATABASE_URI', 'sqlite:///choochootrain.db')
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
# TODO change this later.
app.config['SECURITY_PASSWORD_SALT'] = '$2a$12$skCRnkqE5L01bHEke678Ju'
# See here for all configurable options:
# /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_security
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_CHANGEABLE'] = True
app.config['SECURITY_RECOVERABLE'] = True

app.config['SECURITY_REGISTER_URL'] = '/register'
app.config['SECURITY_REGISTER_USER_TEMPLATE'] = 'authentication/register.html'
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False
app.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'authentication/login.html'
app.config['SECURITY_LOGIN_URL'] = '/signin'
app.config['SECURITY_RESET_URL'] = '/reset_password'

app.config['SECURITY_POST_LOGIN_VIEW'] = 'success'
# Flask security settings: https://pythonhosted.org/Flask-Security/configuration.html
# Flask security templates that we could copy from if we want to reimplement:
# /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_security/templates/security
app.config['SECURITY_CHANGEABLE'] = True
# app.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'base.html'