mirror of
https://onedev.site.tesses.net/tesses-framework
synced 2026-02-08 15:55:46 +00:00
Fix basic auth
This commit is contained in:
@@ -343,6 +343,9 @@ if(TESSESFRAMEWORK_ENABLE_EXAMPLES)
|
|||||||
|
|
||||||
add_executable(runevent examples/runevent.cpp)
|
add_executable(runevent examples/runevent.cpp)
|
||||||
target_link_libraries(runevent PUBLIC tessesframework)
|
target_link_libraries(runevent PUBLIC tessesframework)
|
||||||
|
|
||||||
|
add_executable(tests examples/tests.cpp)
|
||||||
|
target_link_libraries(tests PUBLIC tessesframework)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TESSESFRAMEWORK_ENABLE_APPS)
|
if(TESSESFRAMEWORK_ENABLE_APPS)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <mbedtls/entropy.h>
|
#include <mbedtls/entropy.h>
|
||||||
#include <mbedtls/ctr_drbg.h>
|
#include <mbedtls/ctr_drbg.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <iostream>
|
||||||
namespace Tesses::Framework::Crypto
|
namespace Tesses::Framework::Crypto
|
||||||
{
|
{
|
||||||
bool HaveCrypto()
|
bool HaveCrypto()
|
||||||
@@ -40,12 +41,12 @@ namespace Tesses::Framework::Crypto
|
|||||||
std::vector<uint8_t> Base64_Decode(std::string str)
|
std::vector<uint8_t> Base64_Decode(std::string str)
|
||||||
{
|
{
|
||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
size_t olen;
|
size_t olen=0;
|
||||||
|
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
|
|
||||||
|
|
||||||
mbedtls_base64_decode(data.data(), 0, &olen, (const uint8_t*)str.data(),str.size());
|
mbedtls_base64_decode(data.data(), 0, &olen, (const uint8_t*)str.data(),str.size());
|
||||||
|
|
||||||
data.resize(olen);
|
data.resize(olen);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "TessesFramework/Http/BasicAuthServer.hpp"
|
#include "TessesFramework/Http/BasicAuthServer.hpp"
|
||||||
#include "TessesFramework/Crypto/Crypto.hpp"
|
#include "TessesFramework/Crypto/Crypto.hpp"
|
||||||
|
#include <iostream>
|
||||||
namespace Tesses::Framework::Http {
|
namespace Tesses::Framework::Http {
|
||||||
|
|
||||||
BasicAuthServer::BasicAuthServer()
|
BasicAuthServer::BasicAuthServer()
|
||||||
@@ -39,7 +40,9 @@ namespace Tesses::Framework::Http {
|
|||||||
auto security = HttpUtils::SplitString(auth," ",2);
|
auto security = HttpUtils::SplitString(auth," ",2);
|
||||||
if(security.size() < 2) return false;
|
if(security.size() < 2) return false;
|
||||||
if(security[0] != "Basic") return false;
|
if(security[0] != "Basic") return false;
|
||||||
auto decoded = Crypto::Base64_Decode(security[0]);
|
|
||||||
|
auto decoded = Crypto::Base64_Decode(security[1]);
|
||||||
|
|
||||||
std::string decoded_str(decoded.begin(),decoded.end());
|
std::string decoded_str(decoded.begin(),decoded.end());
|
||||||
security = HttpUtils::SplitString(decoded_str,":",2);
|
security = HttpUtils::SplitString(decoded_str,":",2);
|
||||||
if(security.size() < 2) return false;
|
if(security.size() < 2) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user