NTLM/Kerberos在浏览器上工作,但与Alamofire的应用不使用

发布于 2025-01-30 12:51:37 字数 1453 浏览 2 评论 0原文

由于我们的服务器的身份验证更改,因此我必须在iOS应用中添加Kerberos Authent。我尝试了在互联网上找到的所有内容,但没有任何作用。

这是我的代码

    private static let sessionManager: Session = {
        let configuration = URLSessionConfiguration.default
        configuration.timeoutIntervalForRequest = 25
        configuration.timeoutIntervalForResource = 25
        configuration.urlCredentialStorage = nil

        let retrier = RetryPolicy()
        
        return Session(configuration: configuration, interceptor: retrier)
    }()
    
    private static func performRequest<T: Decodable>(email: String = email ?? "",
                                                     password: String = password ?? "",
                                                     route: APIRouter,
                                                     decoder: JSONDecoder = JSONDecoder(),
                                                     completion: @escaping (AFResult<T>) -> Void) {
        let credential = URLCredential(user: email, password: password, persistence: .permanent)

        sessionManager.request(route)
            .authenticate(with: credential)
            .responseDecodable(decoder: decoder) { completion($0.result) }
    }

,并调用perferrequest,其良好信息会导致不良回报。

同时,如果我去Safari et的路线与良好的标识符联系在一起,我会收到良好的JSON。 我看到的东西很少有挑战,但这似乎是针对较旧版本的Alamofire。

那么,为什么它在浏览器上可以正常工作,而不是在我的应用程序上工作呢?我了解为Safari工作的人们是一个非常好的开发人员,但仍然如此。

谢谢

Since an authentication change in our server, I have to add kerberos authent in our ios app. I tried everything found on internet but nothing works.

Here is my code

    private static let sessionManager: Session = {
        let configuration = URLSessionConfiguration.default
        configuration.timeoutIntervalForRequest = 25
        configuration.timeoutIntervalForResource = 25
        configuration.urlCredentialStorage = nil

        let retrier = RetryPolicy()
        
        return Session(configuration: configuration, interceptor: retrier)
    }()
    
    private static func performRequest<T: Decodable>(email: String = email ?? "",
                                                     password: String = password ?? "",
                                                     route: APIRouter,
                                                     decoder: JSONDecoder = JSONDecoder(),
                                                     completion: @escaping (AFResult<T>) -> Void) {
        let credential = URLCredential(user: email, password: password, persistence: .permanent)

        sessionManager.request(route)
            .authenticate(with: credential)
            .responseDecodable(decoder: decoder) { completion($0.result) }
    }

and calling performRequest with the good info lead to a bad return.

While, if I go to the route on Safari et connect with the good identifiers, I receive the good json.
I saw few things with challenge, but it seems to be for older version of alamofire.

So why it's works fine on browser and not on my app? I understand people working for Safari a very good developers, but still.

Thanks

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文