Ejemplo n.º 1
0
def check_auth(username, password):
    """This function is called to check if a username /
    password combination is valid.
    """
    isDebug = NaFunctions.getConfigOption("Debug")
    server = NaFunctions.getConfigOption("LdapServer")
    base_dn = NaFunctions.getConfigOption("BaseUserDn")
    bind_user="******" + username + "," + base_dn
    tls_cacert_file = NaFunctions.getConfigOption("TLSCACertFile")

    if tls_cacert_file:
        ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, tls_cacert_file)

    if isDebug == True:
        ldap.set_option(ldap.OPT_DEBUG_LEVEL,255)

#     search_filter = "(&(objectClass=person)(uid=" + username + ")(member=cn=dba,cn=groups,cn=accounts," + base_dn + "))"
#     print "Filter is: " + search_filter
    connect = ldap.initialize(server)
    try:
        connect.bind_s(bind_user, password)
#         connect.search_s(base_dn, LDAP_SCOPE_SUBTREE, search_filter)
        connect.unbind_s()
        print("User %s successfully authenticated" % username)
        g.user = username
        g.env = "GENERAL"

        return True
    except Exception:
        connect.unbind_s()
        print("Authentication failed for %s" % username)
        return False
Ejemplo n.º 2
0
    def openDbConn(self):
        server=NaFunctions.getConfigOption("Server", "RFCDBCONN")
        db=NaFunctions.getConfigOption("DB", "RFCDBCONN")
        uid=NaFunctions.getConfigOption("User", "RFCDBCONN")
        password=NaFunctions.getConfigOption("Password", "RFCDBCONN")
        driver=NaFunctions.getConfigOption("Driver", "RFCDBCONN")

        self.connection = pyodbc.connect(driver=driver, server=server, database=db, uid=uid, password=password)
        self.cursor = self.connection.cursor()
Ejemplo n.º 3
0
 def decorated(*args, **kwargs):
     isAuthReq = NaFunctions.getConfigOption("AuthRequired")
     if (isAuthReq == "False"):
         g.user = "******"
         return f(*args, **kwargs)
     auth = request.authorization
     if not auth or not check_auth(auth.username, auth.password):
         return authenticate()
     return f(*args, **kwargs)
Ejemplo n.º 4
0
import logging
from logging.handlers import RotatingFileHandler

from flask import Flask, render_template, request, json
from flask.globals import g
from flask.json import jsonify
from werkzeug.utils import redirect

import LoginAuth
import NaFunctions
import RFCChecker


app = Flask(__name__)
formatter = logging.Formatter("%(asctime)s %(levelname)s %(user)s %(env)s %(funcName)s : %(message)s")
handler = RotatingFileHandler(NaFunctions.getConfigOption("LogFile"), maxBytes=10000000, backupCount=3)
handler.setLevel(logging.INFO)
handler.setFormatter(formatter)
app.logger.addHandler(handler)
app.logger.setLevel(logging.INFO)
app.debug = NaFunctions.getConfigOption("Debug")

@app.route("/")
@LoginAuth.requires_auth
def index():
    return render_template('index.html')

@app.route('/snapmgr')
@app.route('/snapmgr/')
@LoginAuth.requires_auth
def snapmgr_index():
Ejemplo n.º 5
0
from flask.json import jsonify
from werkzeug.utils import redirect

import LoginAuth
import NaFunctions
import RFCChecker


app = Flask(__name__)
formatter = logging.Formatter("%(asctime)s %(levelname)s %(user)s %(env)s %(funcName)s : %(message)s")
handler = RotatingFileHandler("/home/rgroten/git/NetApp-Snapshot-Manager/snapmgr/snapmgr.log", maxBytes=10000000, backupCount=3)
handler.setLevel(logging.INFO)
handler.setFormatter(formatter)
app.logger.addHandler(handler)
app.logger.setLevel(logging.INFO)
app.debug = NaFunctions.getConfigOption("Debug")

@app.route("/")
@LoginAuth.requires_auth
def index():
    return render_template('index.html')

@app.route('/snapmgr')
@app.route('/snapmgr/')
@LoginAuth.requires_auth
def snapmgr_index():
    return redirect('/#/snapmgr')


@app.route('/getenv')
@app.route('/api/get_envs.json')