删除目标c中的身份验证凭据

发布于 2024-11-03 02:11:07 字数 1186 浏览 1 评论 0原文

我正在使用“http://user:[email protected] 等网址发出 HTTP 请求/stuff.xml”,我注意到用户凭据正在获取缓存并使用。如果我尝试首先使用无效凭据登录,则它将不起作用。但是,如果我使用有效的用户名/密码登录,然后尝试使用无效的用户名/密码再次登录,它会使用我刚刚使用的有效凭据,而不是网址中的凭据。

我一直在查看 NSURLCredentialStorage 是否可能删除保存的任何内容,但我需要指定 NSURLProtectionSpace,我不确定那是什么。

更新

我创建了一个 didReceiveAuthenticationChallenge 委托方法,在 NSURLCredential 中设置用户名和密码,并将持久性设置为 NSURLCredentialPersistenceNone >,但似乎委托方法甚至没有被第二次调用。

更新2

似乎无论我做什么,身份验证都会保存在某个地方。其进行身份验证的域似乎没有保存在 sharedCredentialStorage 中。

当我将 canAuthenticateAgainstProtectionSpace 设置为 false 时,它​​不使用 didReceiveAuthenticationChallenge,但身份验证凭据(是 url 的一部分而不是质询响应)似乎仍然得到已缓存!

这个看似简单的问题实际上并不简单,而且非常令人沮丧。这一切可能都是一个错误吗?

I'm making HTTP requests with urls like "http://user:[email protected]/stuff.xml" and I'm noticing that the user credentials are getting cached and used. If I attempt to log in first with invalid credentials, it doesn't work. But if I log in with a valid username/password, then try to login in again with an invalid username/password, it uses the valid credentials I just used rather than what is in the url.

I've been looking at NSURLCredentialStorage to possibly delete whatever is saved, but I need to specify a NSURLProtectionSpace and I'm not sure what that is.

Update:

I made a didReceiveAuthenticationChallenge delegate method that sets the username and password in a NSURLCredential with the persistence set to NSURLCredentialPersistenceNone, but it seems that delegate method doesn't even get called the 2nd time around.

Update 2:

It seems like no matter what I do, the authentication is getting saved somewhere. The domain its authenticating against doesn't seem to be saved in the sharedCredentialStorage.

When I set canAuthenticateAgainstProtectionSpace as false, it doesn't use didReceiveAuthenticationChallenge, but the auth credentials (which are a part of the url rather than the challenge response) still seemed to get cached!

This seemingly straight forward problem isn't turning out to be straight forward and is extremely frustrating. May all of this be a bug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风情万种。 2024-11-10 02:11:07

凭证通常存储为 cookie;尝试删除所有存储的cookie。

Credentials are often stored as cookies; try deleting all stored cookies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文