예제 #1
0
def connect_ldap():
    try:
        ldap = CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PW'])
    except:
        print("Unable to connect to LDAP.")
        raise
    return ldap
예제 #2
0
def connect_ldap():
    try:
        ldap = CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PW'])
    except Exception as e:
        logging.error('unable to connect to LDAP: %s', e)
        raise
    return ldap
예제 #3
0
    def get(self):
        # Do the actual work here
        # Call out to ldap, return a json dict
        # contents: entryUUID, username

        # To move to production, change these initialization values
        # to a user/pass which can search ibuttons
        ldap = CSHLDAP(environ.get('IBUTTON_LDAP_DN'),
                       environ.get('IBUTTON_LDAP_PASS'))
        # get the ibutton from the arguments
        ibutton = self.get_argument('ibutton')
        ibutton = "*" + ibutton[3:] + "01"
        print(ibutton)
        entry = ldap.get_member_ibutton(val=ibutton).__dict__.get('__dn__')
        entry = entry.split(',')
        response = {
            'username': entry[0][4:],
            # entryUUID temporarily disabled while I work out some permissions errors
            # 'entryUUID': entry[1]['entryUUID']
        }
        print(response)
        # return it
        self.write(response)
예제 #4
0
        app.config['OIDC_CLIENT_CONFIG']['client_secret']))
auth = OIDCAuthentication({'default': _config}, app)

# Get s3 bucket for use in functions and templates
s3_bucket = get_bucket(app.config["S3_URL"], app.config["S3_KEY"],
                       app.config["S3_SECRET"], app.config["BUCKET_NAME"])

# Database setup
db = SQLAlchemy(app)
migrate = flask_migrate.Migrate(app, db)

# Import db models after instantiating db object
from audiophiler.models import File, Harold, Auth

# Create CSHLDAP connection
ldap = CSHLDAP(app.config["LDAP_BIND_DN"], app.config["LDAP_BIND_PW"])

# Import ldap functions after creating ldap conn
from audiophiler.ldap import ldap_is_eboard, ldap_is_rtp

# Disable SSL certificate verification warning
requests.packages.urllib3.disable_warnings()


@app.route("/")
@auth.oidc_auth('default')
@audiophiler_auth
def home(auth_dict=None):
    # Retrieve list of files for templating
    db_files = File.query.all()
    harolds = get_harold_list(auth_dict["uid"])
예제 #5
0
파일: ldap.py 프로젝트: mxmeinhold/packet
        :param member: A CSHMember instance
        """
        return self._is_member_of_group(member, 'intromembers')

    def is_on_coop(self, member):
        """
        :param member: A CSHMember instance
        """
        if date.today().month > 6:
            return self._is_member_of_group(member, 'fall_coop')
        else:
            return self._is_member_of_group(member, 'spring_coop')

    def get_roomnumber(self, member):  # pylint: disable=no-self-use
        """
        :param member: A CSHMember instance
        """
        try:
            return member.roomNumber
        except AttributeError:
            return None


if app.config['LDAP_BIND_DN'] and app.config['LDAP_BIND_PASS']:
    ldap = LDAPWrapper(cshldap=CSHLDAP(app.config['LDAP_BIND_DN'],
                                       app.config['LDAP_BIND_PASS']))
else:
    ldap = LDAPWrapper(mock_members=list(
        map(lambda mock_dict: MockMember(**mock_dict),
            app.config['LDAP_MOCK_MEMBERS'])))
예제 #6
0
migrate = flask_migrate.Migrate(app, db)

# Disable SSL certificate verification warning
requests.packages.urllib3.disable_warnings()

app.config["GIT_REVISION"] = subprocess.check_output(['git',
                                                      'rev-parse',
                                                      '--short',
                                                      'HEAD']).decode('utf-8').rstrip()


auth = OIDCAuthentication(app,
                          issuer=app.config['OIDC_ISSUER'],
                          client_registration_info=app.config['OIDC_CLIENT_CONFIG'])

ldap = CSHLDAP(app.config['LDAP_BIND_DN'],
               app.config['LDAP_BIND_PW'])

s3 = S3('s3.csh.rit.edu',
           access_key=app.config['S3_ACCESS_ID'],
           secret_key=app.config['S3_SECRET_KEY'],
           secure=True)

# pylint: disable=C0413
from gallery.models import Directory
from gallery.models import File
from gallery.models import Tag

from gallery.util import DEFAULT_THUMBNAIL_NAME
from gallery.util import ROOT_DIR_ID
from gallery.util import get_dir_file_contents
from gallery.util import get_full_dir_path
예제 #7
0
from terminaltables import AsciiTable
from proxmoxer import ProxmoxAPI
from csh_ldap import CSHLDAP
from sys import stderr

import secrets

ldap = CSHLDAP(secrets.ldap_user, secrets.ldap_pass)
proxmox = ProxmoxAPI('proxmox01.csh.rit.edu',
                     user=secrets.pm_user,
                     password=secrets.pm_pass,
                     verify_ssl=False)

dues_table = [["User", "#", "CPU", "RAM", "Disk", "Dues"]]

users = {}
inactive_users = []


def is_active(member):
    group_list = member.get("memberOf")
    if "cn=active,ou=Groups,dc=csh,dc=rit,dc=edu" in group_list:
        return True
    return False


for vm in proxmox.cluster.resources.get(type="vm"):
    if 'pool' in vm:
        if vm['pool'] in users:
            users[vm['pool']].append(vm)
        else:
예제 #8
0
# Disable SSL certificate verification warning
requests.packages.urllib3.disable_warnings()

auth = OIDCAuthentication({
    'default': ProviderConfiguration(
        issuer=app_config['OIDC_ISSUER'],
        client_metadata=ClientMetadata(
            client_id=app_config['OIDC_CLIENT_ID'],
            client_secret=app_config['OIDC_CLIENT_SECRET']
        )
    )
}, app)

if "LDAP_BIND_DN" in app.config:
    ldap = LDAPWrapper(CSHLDAP(
        app.config['LDAP_BIND_DN'],
        app.config['LDAP_BIND_PW'],
    ))
else:
    ldap = LDAPWrapper(
        None,
        app.config.get("EBOARD_UIDS", "").split(","),
        app.config.get("RTP_UIDS", "").split(","),
    )

app.add_template_global(ldap, name="ldap")

storage_interface: FileStorage
if "LOCAL_STORAGE_PATH" in app.config:
    storage_interface = LocalStorage(app)
elif "S3_URI" in app.config:
    storage_interface = S3Storage(app)
예제 #9
0
import os
from csh_uuid_http import app

from csh_ldap import CSHLDAP

if os.path.exists(os.path.join(os.getcwd(), "config.py")):
    app.config.from_pyfile(os.path.join(os.getcwd(), "config.py"))
else:
    app.config.from_pyfile(os.path.join(os.getcwd(), "config.env.py"))

app.config['LDAP_CONN'] = CSHLDAP(app.config['LDAP_BIND_DN'],
                                  app.config['LDAP_BIND_PW'])
if __name__ == '__main__':
    app.run(host=app.config['IP'], port=app.config['PORT'])

application = app