當前位置: 首頁>>代碼示例>>Python>>正文


Python kerberos.authGSSClientInit方法代碼示例

本文整理匯總了Python中kerberos.authGSSClientInit方法的典型用法代碼示例。如果您正苦於以下問題:Python kerberos.authGSSClientInit方法的具體用法?Python kerberos.authGSSClientInit怎麽用?Python kerberos.authGSSClientInit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kerberos的用法示例。


在下文中一共展示了kerberos.authGSSClientInit方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _set_username

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def _set_username(self, **kwargs):
        if self._username is not None:
            return
        try:
            (ret, ctx) = kerberos.authGSSClientInit('krbtgt@REDHAT.COM')
            assert (ret == kerberos.AUTH_GSS_COMPLETE)
            ret = kerberos.authGSSClientInquireCred(ctx)
            assert (ret == kerberos.AUTH_GSS_COMPLETE)
            # XXX What if you have >1 ticket?
            ret = kerberos.authGSSClientUserName(ctx)
            if '@' in ret:
                self._username = ret.split('@')[0]
            else:
                self._username = ret
        except AssertionError:
            raise ErrataException('Pigeon crap. Did it forget to run kinit?')

    # Shortcut 
開發者ID:red-hat-storage,項目名稱:errata-tool,代碼行數:20,代碼來源:connector.py

示例2: refresh_auth

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def refresh_auth(self):
        service = "HTTP@" + self.hostname
        flags = kerberos.GSS_C_MUTUAL_FLAG | kerberos.GSS_C_SEQUENCE_FLAG
        try:
            (_, vc) = kerberos.authGSSClientInit(service, flags)
        except kerberos.GSSError as e:
            LOG.error(_LE("caught kerberos exception %r") % e)
            raise IPAAuthError(str(e))
        try:
            kerberos.authGSSClientStep(vc, "")
        except kerberos.GSSError as e:
            LOG.error(_LE("caught kerberos exception %r") % e)
            raise IPAAuthError(str(e))
        self.token = kerberos.authGSSClientResponse(vc) 
開發者ID:openstack,項目名稱:designate,代碼行數:16,代碼來源:auth.py

示例3: get_auth_header

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def get_auth_header(self):
        if self.ctx:
            raise RuntimeError("Context has already been initialized")
        __, self.ctx = kerberos.authGSSClientInit(self.service, principal = self.principal)
        kerberos.authGSSClientStep(self.ctx, "")
        token = kerberos.authGSSClientResponse(self.ctx)
        return {"Authorization": "Negotiate " + token} 
開發者ID:exasol,項目名稱:script-languages,代碼行數:9,代碼來源:gss.py

示例4: gssclient_token

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def gssclient_token(self):
        os.environ['KRB5_CLIENT_KTNAME'] = self.IQUOTA_KEYTAB

        service = "HTTP@" + self.IQUOTA_API_HOST

        try:
            (_, vc) = kerberos.authGSSClientInit(service)
            kerberos.authGSSClientStep(vc, "")
            return kerberos.authGSSClientResponse(vc)
        except kerberos.GSSError as e:
            raise KerberosError('error initializing GSS client') 
開發者ID:ubccr,項目名稱:coldfront,代碼行數:13,代碼來源:utils.py

示例5: _create_kerberos_session

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def _create_kerberos_session(self, kerberos_service):
        try:
            import kerberos as kerb
        except ImportError as e:
            log.debug(e)
            try:
                import kerberos_sspi as kerb
            except ImportError:
                raise ImportError("No kerberos implementation available")
        __, krb_context = kerb.authGSSClientInit(kerberos_service)
        kerb.authGSSClientStep(krb_context, "")
        auth_header = ("Negotiate " + kerb.authGSSClientResponse(krb_context))
        self._update_header("Authorization", auth_header)
        response = self._session.get(self.url, verify=self.verify_ssl)
        response.raise_for_status() 
開發者ID:atlassian-api,項目名稱:atlassian-python-api,代碼行數:17,代碼來源:rest_client.py

示例6: _negotiate_get_svctk

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def _negotiate_get_svctk(self, spn, authdata):
    if authdata is None:
      return None

    result, self.context = kerberos.authGSSClientInit(spn)
    if result < kerberos.AUTH_GSS_COMPLETE:
      return None

    result = kerberos.authGSSClientStep(self.context, authdata)
    if result < kerberos.AUTH_GSS_CONTINUE:
      return None

    response = kerberos.authGSSClientResponse(self.context)
    return "Negotiate %s" % response 
開發者ID:GerritCodeReview,項目名稱:git-repo,代碼行數:16,代碼來源:main.py

示例7: pre_request

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def pre_request(self, resp):
        # TODO: convert errors to some common error class
        import kerberos

        _, context = kerberos.authGSSClientInit(
            "HTTP@%s" % resp.url.host,
            gssflags=kerberos.GSS_C_MUTUAL_FLAG | kerberos.GSS_C_SEQUENCE_FLAG,
        )
        kerberos.authGSSClientStep(context, "")
        response = kerberos.authGSSClientResponse(context)
        headers = {"Authorization": "Negotiate " + response}
        return headers, context 
開發者ID:dask,項目名稱:dask-gateway,代碼行數:14,代碼來源:auth.py

示例8: start

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def start(self, username, authzid):
        self.username = username
        self.authzid = authzid
        _unused, self._gss = kerberos.authGSSClientInit(authzid or 
                        "{0}@{1}".format("xmpp", 
                                    self.password_manager.get_serv_host()))
        self.step = 0
        return self.challenge("") 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:10,代碼來源:gssapi.py

示例9: setup

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def setup(self, name):
            authzid = self.credentials['authzid']
            if not authzid:
                authzid = 'xmpp@%s' % self.credentials['service-name']

            _, self.gss = kerberos.authGSSClientInit(authzid)
            self.step = 0 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:9,代碼來源:mechanisms.py

示例10: _get_bearer_saml_assertion_lin

# 需要導入模塊: import kerberos [as 別名]
# 或者: from kerberos import authGSSClientInit [as 別名]
def _get_bearer_saml_assertion_lin(self,
                                       request_duration=60,
                                       token_duration=600,
                                       delegatable=False,
                                       renewable=False):
        '''
        Extracts the assertion from the Bearer Token received from the Security
        Token Service using kerberos.

        @type  request_duration: C{long}
        @param request_duration: The duration for which the request is valid. If
                                 the STS receives this request after this
                                 duration, it is assumed to have expired. The
                                 duration is in seconds and the default is 60s.
        @type    token_duration: C{long}
        @param   token_duration: The duration for which the SAML token is issued
                                 for. The duration is specified in seconds and
                                 the default is 600s.
        @type       delegatable: C{boolean}
        @param      delegatable: Whether the generated token is delegatable or not
                                 The default value is False
        @type         renewable: C{boolean}
        @param        renewable: Whether the generated token is renewable or not
                                 The default value is False
        @rtype: C{str}
        @return: The SAML assertion in Unicode.
        '''
        import kerberos
        import platform
        service = 'host@%s' % platform.node()
        _, context = kerberos.authGSSClientInit(service, 0)
        challenge = ''
        # The following will keep running unless we receive a saml token or an error
        while True:
            # Call GSS step
            result = kerberos.authGSSClientStep(context, challenge)
            if result < 0:
                break
            sectoken = kerberos.authGSSClientResponse(context)
            soap_response = self._get_gss_soap_response(sectoken,
                                request_duration, token_duration, delegatable,
                                renewable)
            et = etree.fromstring(soap_response)
            try:
                # Check if we have received a challenge token from the server
                element = _extract_element(et,
                        'BinaryExchange',
                        {'ns': "http://docs.oasis-open.org/ws-sx/ws-trust/200512"})
                negotiate_token = element.text
                challenge = negotiate_token
            except KeyError:
                # Response does not contain the negotiate token.
                # It should contain SAML token then.
                saml_token = etree.tostring(
                    _extract_element(
                        et,
                        'Assertion',
                        {'saml2': "urn:oasis:names:tc:SAML:2.0:assertion"}),
                    pretty_print=False).decode(UTF_8)
                break
        return saml_token 
開發者ID:vmware,項目名稱:vsphere-automation-sdk-python,代碼行數:63,代碼來源:sso.py


注:本文中的kerberos.authGSSClientInit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。