1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

API: Support HTTP basic authentication for API. v6.0.4, v5.0.152 (#3458)

Co-authored-by: winlin <winlin@vip.126.com>
Co-authored-by: john <hondaxiao@tencent.com>
This commit is contained in:
Haibo Chen 2023-04-01 12:45:29 +08:00 committed by GitHub
parent 571043ff3d
commit 771ae0a1a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 660 additions and 50 deletions

View file

@ -482,24 +482,46 @@ private:
virtual bool path_match(std::string pattern, std::string path);
};
// The filter http mux, directly serve the http CORS requests,
// while proxy to the worker mux for services.
// The filter http mux, directly serve the http CORS requests
class SrsHttpCorsMux : public ISrsHttpHandler
{
private:
bool required;
bool enabled;
ISrsHttpServeMux* next;
ISrsHttpHandler* next_;
public:
SrsHttpCorsMux();
SrsHttpCorsMux(ISrsHttpHandler* h);
virtual ~SrsHttpCorsMux();
public:
virtual srs_error_t initialize(ISrsHttpServeMux* worker, bool cros_enabled);
virtual srs_error_t initialize(bool cros_enabled);
// Interface ISrsHttpServeMux
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
// The filter http mux, directly serve the http AUTH requests,
// while proxy to the worker mux for services.
// @see https://www.rfc-editor.org/rfc/rfc7617
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate
class SrsHttpAuthMux : public ISrsHttpHandler
{
private:
bool enabled_;
std::string username_;
std::string password_;
ISrsHttpHandler* next_;
public:
SrsHttpAuthMux(ISrsHttpHandler* h);
virtual ~SrsHttpAuthMux();
public:
virtual srs_error_t initialize(bool enabled, std::string username, std::string password);
// Interface ISrsHttpServeMux
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
private:
virtual srs_error_t do_auth(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
// A Request represents an HTTP request received by a server
// or to be sent by a client.
//