删除目标c中的身份验证凭据
我正在使用“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
凭证通常存储为 cookie;尝试删除所有存储的cookie。
Credentials are often stored as cookies; try deleting all stored cookies.