Exemple #1
0
def create_authenticator(auth_object, temp_folder):
    auth_type = auth_object.get('type')

    if not auth_type:
        raise Exception('Auth type should be specified')

    auth_type = auth_type.strip().lower()
    if auth_type == 'ldap':
        from auth.auth_ldap import LdapAuthenticator
        authenticator = LdapAuthenticator(auth_object, temp_folder)
    elif auth_type == 'google_oauth':
        from auth.auth_google_oauth import GoogleOauthAuthenticator
        authenticator = GoogleOauthAuthenticator(auth_object)
    elif auth_type == 'gitlab':
        from auth.auth_gitlab import GitlabOAuthAuthenticator
        authenticator = GitlabOAuthAuthenticator(auth_object)
    elif auth_type == 'htpasswd':
        from auth.auth_htpasswd import HtpasswdAuthenticator
        authenticator = HtpasswdAuthenticator(auth_object)
    else:
        raise Exception(auth_type + ' auth is not supported')

    authenticator.auth_expiration_days = float(
        auth_object.get('expiration_days', 30))

    authenticator.auth_type = auth_type

    return authenticator
Exemple #2
0
def create_authenticator(auth_object, temp_folder):
    auth_type = auth_object.get('type')

    if not auth_type:
        raise Exception('Auth type should be specified')

    auth_type = auth_type.strip().lower()
    if auth_type == 'ldap':
        from auth.auth_ldap import LdapAuthenticator
        authenticator = LdapAuthenticator(auth_object, temp_folder)
    elif auth_type == 'google_oauth':
        from auth.auth_google_oauth import GoogleOauthAuthenticator
        authenticator = GoogleOauthAuthenticator(auth_object)
    else:
        raise Exception(auth_type + ' auth is not supported')

    authenticator.auth_type = auth_type

    return authenticator