def __call__(self, r): cred_store = [("client_keytab", self.keytab)] my_cred = gssapi.gss_acquire_cred_from(cred_store, gssapi._NULL) username = gssapi.gss_import_name(self.user, gssapi.GSS_C_NT_USER_NAME) usercred = gssapi.gss_acquire_cred_impersonate_name(my_cred, username) return self._authenticate(r, usercred)
def _authenticate(self, r, user_cred): svc_host = urlparse.urlparse(r.url).netloc svc_name = gssapi.gss_import_name("HTTP@" + svc_host, gssapi.GSS_C_NT_HOSTBASED_SERVICE) _, token = gssapi.gss_init_sec_context(user_cred, svc_name) r.headers["Authorization"] = "Negotiate " + base64.b64encode(token) return r
def __call__(self, r): username = gssapi.gss_import_name(self.user, gssapi.GSS_C_NT_USER_NAME) usercred = gssapi.gss_acquire_cred(username) return self._authenticate(r, usercred)