Ejemplo n.º 1
0
 def __init__(self):
     self.LDAP_HOST = config.get('ldap', 'host')
     self.LDAP_PORT = int(config.get('ldap', 'port'))
     self.LDAP_PROTO = 'ldaps' if config.getboolean('ldap', 'ssl') else 'ldap'
     self.LDAP_BIND_METHOD = config.get('ldap', 'bind_method')
     self.LDAP_BASE = config.get('ldap', 'base')
     self.LDAP_BIND_DN = config.get('ldap', 'bind_dn')
     self.LDAP_PASS = config.get('ldap', 'password')
     self.ID_MAPPING = config.get('ldap', 'id_mapping')
     self.DISPLAY_MAPPING = config.get('ldap', 'display_mapping')
     self.OBJECT_CLASS = config.get('ldap', 'object_class')
     self.REQUIRED_GROUP = config.get('ldap', 'required_group')
Ejemplo n.º 2
0
 def __init__(self):
     self.LDAP_HOST = config.get('ldap', 'host')
     self.LDAP_PORT = int(config.get('ldap', 'port'))
     self.LDAP_PROTO = 'ldaps' if config.getboolean('ldap',
                                                    'ssl') else 'ldap'
     self.LDAP_BIND_METHOD = config.get('ldap', 'bind_method')
     self.LDAP_BASE = config.get('ldap', 'base')
     self.LDAP_BIND_DN = config.get('ldap', 'bind_dn')
     self.LDAP_PASS = config.get('ldap', 'password')
     self.ID_MAPPING = config.get('ldap', 'id_mapping')
     self.DISPLAY_MAPPING = config.get('ldap', 'display_mapping')
     self.OBJECT_CLASS = config.get('ldap', 'object_class')
     self.REQUIRED_GROUP = config.get('ldap', 'required_group')
Ejemplo n.º 3
0
import re
import time
import socket
import subprocess
import ConfigParser

from flask import Blueprint, request, session, g, redirect, url_for, abort, render_template, flash, jsonify

import lwp
import lwp.lxclite as lxc
from lwp.utils import query_db, if_logged_in, get_bucket_token, hash_passwd, config, cgroup_ext
from lwp.views.auth import AUTH

# TODO: see if we can move this block somewhere better
try:
    USE_BUCKET = config.getboolean('global', 'buckets')
    BUCKET_HOST = config.get('buckets', 'buckets_host')
    BUCKET_PORT = config.get('buckets', 'buckets_port')
except ConfigParser.NoOptionError:
    USE_BUCKET = False
    print("- Bucket feature disabled")

storage_repos = config.items('storage_repository')

# Flask module
mod = Blueprint('main', __name__)


@mod.route('/')
@mod.route('/home')
@if_logged_in()
Ejemplo n.º 4
0
import re
import time
import socket
import subprocess
import ConfigParser

from flask import Blueprint, request, session, g, redirect, url_for, abort, render_template, flash, jsonify

import lwp
import lwp.lxclite as lxc
from lwp.utils import query_db, if_logged_in, get_bucket_token, hash_passwd, config, cgroup_ext
from lwp.views.auth import AUTH

# TODO: see if we can move this block somewhere better
try:
    USE_BUCKET = config.getboolean('global', 'buckets')
    BUCKET_HOST = config.get('buckets', 'buckets_host')
    BUCKET_PORT = config.get('buckets', 'buckets_port')
except ConfigParser.NoOptionError:
    USE_BUCKET = False
    print("- Bucket feature disabled")


storage_repos = config.items('storage_repository')

# Flask module
mod = Blueprint('main', __name__)


@mod.route('/')
@mod.route('/home')
Ejemplo n.º 5
0
import os
import sys

from flask import Flask, g

from lwp.utils import connect_db, check_session_limit, config
from lwp import SESSION_SECRET_FILE
from lwp.views import main, auth, api

try:
    SECRET_KEY = open(SESSION_SECRET_FILE, 'r').read()
except IOError:
    print(' * Missing session_secret file, your session will not survive server reboot. Run with --generate-session-secret to generate permanent file.')
    SECRET_KEY = os.urandom(24)

DEBUG = config.getboolean('global', 'debug')
DATABASE = config.get('database', 'file')
ADDRESS = config.get('global', 'address')
PORT = int(config.get('global', 'port'))
PREFIX = config.get('global', 'prefix')

# Flask app
app = Flask('lwp', static_url_path="{0}/static".format(PREFIX))
app.config.from_object(__name__)
app.register_blueprint(main.mod, url_prefix=PREFIX)
app.register_blueprint(auth.mod, url_prefix=PREFIX)
app.register_blueprint(api.mod, url_prefix=PREFIX)


if '--profiling' in sys.argv[1:]:
    from werkzeug.contrib.profiler import ProfilerMiddleware
Ejemplo n.º 6
0
from flask import Flask, g

from lwp.utils import connect_db, check_session_limit, config
from lwp import SESSION_SECRET_FILE
from lwp.views import main, auth, api

try:
    SECRET_KEY = open(SESSION_SECRET_FILE, 'r').read()
except IOError:
    print(
        ' * Missing session_secret file, your session will not survive server reboot. Run with --generate-session-secret to generate permanent file.'
    )
    SECRET_KEY = os.urandom(24)

DEBUG = config.getboolean('global', 'debug')
DATABASE = config.get('database', 'file')
ADDRESS = config.get('global', 'address')
PORT = int(config.get('global', 'port'))
PREFIX = config.get('global', 'prefix')

# Flask app
app = Flask('lwp', static_url_path="{0}/static".format(PREFIX))
app.config.from_object(__name__)
app.register_blueprint(main.mod, url_prefix=PREFIX)
app.register_blueprint(auth.mod, url_prefix=PREFIX)
app.register_blueprint(api.mod, url_prefix=PREFIX)

if '--profiling' in sys.argv[1:]:
    from werkzeug.contrib.profiler import ProfilerMiddleware
    app.config['PROFILE'] = True
Ejemplo n.º 7
0
import time

from flask import Blueprint, request, session, redirect, url_for, render_template, flash

from lwp.utils import query_db, hash_passwd, get_token, config

# TODO: see if we can move this block somewhere better
try:
    AUTH = config.get('global', 'auth')
    print(' * Auth type: ' + AUTH)
    if AUTH == 'ldap':
        import ldap
        LDAP_HOST = config.get('ldap', 'host')
        LDAP_PORT = int(config.get('ldap', 'port'))
        LDAP_PROTO = 'ldaps' if config.getboolean('ldap', 'ssl') else 'ldap'
        LDAP_BIND_METHOD = config.get('ldap', 'bind_method')
        LDAP_BASE = config.get('ldap', 'base')
        LDAP_BIND_DN = config.get('ldap', 'bind_dn')
        LDAP_PASS = config.get('ldap', 'password')
        ID_MAPPING = config.get('ldap', 'id_mapping')
        DISPLAY_MAPPING = config.get('ldap', 'display_mapping')
        OBJECT_CLASS = config.get('ldap', 'object_class')
        REQUIRED_GROUP = config.get('ldap', 'required_group')
    elif AUTH == 'htpasswd':
        HTPASSWD_FILE = config.get('htpasswd', 'file')
    elif AUTH == 'pam':
        import pam
        PAM_SERVICE = config.get('pam', 'service')
except NameError as err:
    print(' ! Revert to DB authentication ' + str(err))
Ejemplo n.º 8
0
if "--generate-session-secret" in sys.argv[1:]:
    key = os.urandom(24)
    with os.fdopen(os.open(SESSION_SECRET_FILE, os.O_WRONLY | os.O_CREAT, 0644), "w") as handle:
        handle.write(key)
    exit(0)

try:
    SECRET_KEY = open(SESSION_SECRET_FILE, "r").read()
except IOError:
    print(
        " * Missing session_secret file, your session will not survive server reboot. Run with --generate-session-secret to generate permanent file."
    )
    SECRET_KEY = os.urandom(24)

DEBUG = config.getboolean("global", "debug")
DATABASE = config.get("database", "file")
ADDRESS = config.get("global", "address")
PORT = int(config.get("global", "port"))
PREFIX = config.get("global", "prefix")

# Flask app
app = Flask("lwp", static_url_path="{0}/static".format(PREFIX))
app.config.from_object(__name__)
app.register_blueprint(main.mod, url_prefix=PREFIX)
app.register_blueprint(auth.mod, url_prefix=PREFIX)
app.register_blueprint(api.mod, url_prefix=PREFIX)


if "--profiling" in sys.argv[1:]:
    from werkzeug.contrib.profiler import ProfilerMiddleware