| 235 | } |
| 236 | |
| 237 | Status BasicAuthExtractCredentials( |
| 238 | const string& token, string& username, string& password) { |
| 239 | if (token.empty()) { |
| 240 | return Status::Expected("Empty token"); |
| 241 | } |
| 242 | string decoded; |
| 243 | if (!Base64Unescape(token, &decoded)) { |
| 244 | return Status::Expected("Failed to decode base64 basic authentication token."); |
| 245 | } |
| 246 | std::size_t colon = decoded.find(':'); |
| 247 | if (colon == std::string::npos) { |
| 248 | return Status::Expected("Invalid basic authentication token format, must be in the " |
| 249 | "form '<username>:<password>'"); |
| 250 | } |
| 251 | username = decoded.substr(0, colon); |
| 252 | password = decoded.substr(colon + 1); |
| 253 | return Status::OK(); |
| 254 | } |
| 255 | |
| 256 | } // namespace impala |
no test coverage detected