Commit a10061b5 authored by jan.koester's avatar jan.koester
Browse files

test

parent 3933018e
Loading
Loading
Loading
Loading
+9 −1
Changes for editor/src/webedit_mcp.cpp: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#include <algorithm>
#include <cctype>
#include <cstring>
#include <initializer_list>

@@ -166,8 +168,14 @@ bool webedit::Mcp::authenticate(libhttppp::HttpRequest &curreq, std::string &own
        return false;

    std::string authVal = authHdr->getfirstValue()->getvalue();
    // RFC 7235: the auth-scheme token ("Bearer") is case-insensitive, so
    // clients sending "bearer <token>" must still be accepted here.
    static const std::string prefix = "Bearer ";
    if (authVal.rfind(prefix, 0) != 0)
    bool hasPrefix = authVal.size() >= prefix.size() &&
        std::equal(prefix.begin(), prefix.end(), authVal.begin(), [](unsigned char a, unsigned char b) {
            return std::tolower(a) == std::tolower(b);
        });
    if (!hasPrefix)
        return false;

    std::string token = authVal.substr(prefix.size());