deadbeef | f137e97 | 2017-03-23 15:45:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef RTC_BASE_HTTP_COMMON_H_ |
| 12 | #define RTC_BASE_HTTP_COMMON_H_ |
deadbeef | f137e97 | 2017-03-23 15:45:49 -0700 | [diff] [blame] | 13 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 14 | #include <string> |
deadbeef | f137e97 | 2017-03-23 15:45:49 -0700 | [diff] [blame] | 15 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 16 | namespace rtc { |
deadbeef | f137e97 | 2017-03-23 15:45:49 -0700 | [diff] [blame] | 17 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 18 | class CryptString; |
| 19 | class SocketAddress; |
| 20 | |
| 21 | ////////////////////////////////////////////////////////////////////// |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 22 | // Http Authentication |
| 23 | ////////////////////////////////////////////////////////////////////// |
| 24 | |
| 25 | struct HttpAuthContext { |
| 26 | std::string auth_method; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 27 | HttpAuthContext(const std::string& auth) : auth_method(auth) {} |
| 28 | virtual ~HttpAuthContext() {} |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | enum HttpAuthResult { HAR_RESPONSE, HAR_IGNORE, HAR_CREDENTIALS, HAR_ERROR }; |
| 32 | |
| 33 | // 'context' is used by this function to record information between calls. |
| 34 | // Start by passing a null pointer, then pass the same pointer each additional |
| 35 | // call. When the authentication attempt is finished, delete the context. |
Joachim Bauch | 5b32f23 | 2018-03-07 20:02:26 +0100 | [diff] [blame] | 36 | // TODO(bugs.webrtc.org/8905): Change "response" to "ZeroOnFreeBuffer". |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 37 | HttpAuthResult HttpAuthenticate(const char* challenge, |
| 38 | size_t len, |
| 39 | const SocketAddress& server, |
| 40 | const std::string& method, |
| 41 | const std::string& uri, |
| 42 | const std::string& username, |
| 43 | const CryptString& password, |
| 44 | HttpAuthContext*& context, |
| 45 | std::string& response, |
| 46 | std::string& auth_method); |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 47 | |
| 48 | ////////////////////////////////////////////////////////////////////// |
| 49 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 50 | } // namespace rtc |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 51 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 52 | #endif // RTC_BASE_HTTP_COMMON_H_ |