Parcourir la source

Accept NTLM and Negotiate as valid authentication methods (#2975)

* Accept NTLM and Negotiate as valid auth methods

* Rename attemptHTTPAuthentication

* Align function declaration
Adrian Kashivskyy il y a 6 ans
Parent
commit
77a6e52dc0
1 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 5 5
      Source/SessionDelegate.swift

+ 5 - 5
Source/SessionDelegate.swift

@@ -79,8 +79,8 @@ extension SessionDelegate: URLSessionTaskDelegate {
         switch challenge.protectionSpace.authenticationMethod {
         case NSURLAuthenticationMethodServerTrust:
             evaluation = attemptServerTrustAuthentication(with: challenge)
-        case NSURLAuthenticationMethodHTTPBasic, NSURLAuthenticationMethodHTTPDigest:
-            evaluation = attemptHTTPAuthentication(for: challenge, belongingTo: task)
+        case NSURLAuthenticationMethodHTTPBasic, NSURLAuthenticationMethodHTTPDigest, NSURLAuthenticationMethodNTLM, NSURLAuthenticationMethodNegotiate:
+            evaluation = attemptCredentialAuthentication(for: challenge, belongingTo: task)
         // case NSURLAuthenticationMethodClientCertificate:
         // Alamofire doesn't currently support client certificate validation.
         default:
@@ -121,15 +121,15 @@ extension SessionDelegate: URLSessionTaskDelegate {
         }
     }
 
-    /// Evaluates the HTTP authentication `URLAuthenticationChallenge` received for `task`.
+    /// Evaluates the credential-based authentication `URLAuthenticationChallenge` received for `task`.
     ///
     /// - Parameters:
     ///   - challenge: The `URLAuthenticationChallenge`.
     ///   - task:      The `URLSessionTask` which received the challenge.
     ///
     /// - Returns:     The `ChallengeEvaluation`.
-    func attemptHTTPAuthentication(for challenge: URLAuthenticationChallenge,
-                                   belongingTo task: URLSessionTask) -> ChallengeEvaluation {
+    func attemptCredentialAuthentication(for challenge: URLAuthenticationChallenge,
+                                         belongingTo task: URLSessionTask) -> ChallengeEvaluation {
         guard challenge.previousFailureCount == 0 else {
             return (.rejectProtectionSpace, nil, nil)
         }