예제 #1
0
    def __init__(self):
        FilebasedUserManager.__init__(self)

        self.url = (settings().get(['accessControl', 'fabman', 'url'])
                    or self.FABMAN_API_URL).rstrip('/')
        self.fabman_enabled = settings().getBoolean(
            ['accessControl', 'fabman', 'enabled']) or False
        self.local_enabled = settings().getBoolean(
            ['accessControl', 'fabman', 'allowLocalUsers']) or False
        self.fabman_account = settings().getInt(
            ['accessControl', 'fabman', 'accountId'])
        self.restrict_access = settings().getBoolean(
            ['accessControl', 'fabman', 'restrictAccess']) or False
        self.resource_set = set(
            settings().get(['accessControl', 'fabman', 'resourceIds']) or [])

        # { username: (id, cookie) }
        self.fabman_users = {}
예제 #2
0
    def __init__(self, components, settings):
        OAuthbasedUserManager.logger.info("Initializing OAuthbasedUserManager")
        self._components = components
        self._settings = settings

        # Get data from config file
        self.oauth2 = self._settings.get(["plugins", "oauth2"])
        self.path_for_token = self.oauth2["token_path"]
        self.path_user_info = self.oauth2["user_info_path"]
        self.username_key = self.oauth2["username_key"]
        self.access_token_query_key = self.oauth2["access_token_query_key"]
        try:
            self.token_headers = self.oauth2["token_headers"]
        except KeyError:
            self.token_headers = None

        # Init FilebasedUserManager, other methods are needed for OctoPrint
        FilebasedUserManager.__init__(self)
예제 #3
0
    def __init__(self):
        if settings().get(["accessControl", "userManager"
                           ]) == 'octoprint_authldap.LDAPUserManager':
            if settings().get(["plugins", "authldap", "ldap_uri"]) is not None\
              and settings().get(["plugins", "authldap", "ldap_bind_user"]) is not None \
              and settings().get(["plugins", "authldap", "ldap_bind_password"]) is not None \
              and settings().get(["plugins", "authldap", "ldap_search_base"]) is not None \
              and settings().get(["plugins", "authldap", "ldap_query"]) is not None:
                connection = ldap.initialize(settings().get(
                    ["plugins", "authldap", "ldap_uri"]))
                connection.set_option(ldap.OPT_REFERRALS, 0)
                if settings().get(["plugins", "authldap",
                                   "ldap_method"]) == 'SECURE':
                    ldap_verifypeer = settings().get(
                        ["plugins", "authldap", "ldap_tls_reqcert"])
                    verifypeer = ldap.OPT_X_TLS_HARD
                    if ldap_verifypeer == 'NEVER':
                        verifypeer = ldap.OPT_X_TLS_NEVER
                    elif ldap_verifypeer == 'ALLOW':
                        verifypeer = ldap.OPT_X_TLS_ALLOW
                    elif ldap_verifypeer == 'TRY':
                        verifypeer = ldap.OPT_X_TLS_TRY
                    elif ldap_verifypeer == 'DEMAND':
                        verifypeer = ldap.OPT_X_TLS_DEMAND
                    # elif ldap_verifypeer == 'HARD':
                    #   verifypeer = ldap.OPT_X_TLS_HARD
                    connection.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,
                                          verifypeer)
                    try:
                        connection.start_tls_s()
                    except:
                        pass
                try:
                    connection.simple_bind_s(
                        settings().get(
                            ["plugins", "authldap", "ldap_bind_user"]),
                        settings().get(
                            ["plugins", "authldap", "ldap_bind_password"]))
                    connection.unbind_s()

                    FilebasedUserManager.__init__(self)
                    return
                except:
                    pass