Skip to content

Commit

Permalink
fix: Colons in the password of a HTTP Basic Authentication. (#55)
Browse files Browse the repository at this point in the history
The existing code was taking the first component of the colon-separated array as the user name,
and the second as the password. In fact, all components after the first must be treated as belonging
to the password.
  • Loading branch information
drewmccormack authored and ianpartridge committed Nov 5, 2018
1 parent 660c43c commit b107a6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/CredentialsHTTP/CredentialsHTTPBasic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ public class CredentialsHTTPBasic : CredentialsPluginProtocol {
authorization = userAuthorization as String
}

let credentials = authorization.components(separatedBy: ":")
guard credentials.count >= 2 else {
let credentials = authorization.split(separator: ":", maxSplits: 1)
guard credentials.count == 2 else {
onFailure(.badRequest, nil)
return
}

let userid = credentials[0]
let password = credentials[1]
let userid = String(credentials[0])
let password = String(credentials[1])

if let userProfileLoader = self.userProfileLoader {
userProfileLoader(userid) { userProfile, storedPassword in
Expand Down

0 comments on commit b107a6d

Please sign in to comment.