12#include <asio/experimental/awaitable_operators.hpp>
13using namespace asio::experimental::awaitable_operators;
15#include <absl/container/flat_hash_map.h>
16#include <spdlog/spdlog.h>
18#include <secp256k1_recovery.h>
19#include <jwt-cpp/jwt.h>
25#include <evmc/evmc.hpp>
27 #define interface __STRUCT__
41 template<http::Header HeaderType>
51 template<http::Header HeaderType>
63 template<http::Header HeaderType>
73 template<http::Header HeaderType>
110 asio::awaitable<bool>
verifyNonce(
const evmc::address &
address,
const std::string & nonce);
116 asio::awaitable<std::expected<evmc::address, AuthenticationError>>
verifyAccessToken(std::string
token)
const;
122 asio::awaitable<std::expected<evmc::address, AuthenticationError>>
verifyRefreshToken(std::string
token)
const;
125 asio::strand<asio::io_context::executor_type> _strand;
127 const std::string _SECRET;
130 std::uniform_int_distribution<int> _dist;
131 absl::flat_hash_map<evmc::address, std::string> _nonces;
133 absl::flat_hash_map<evmc::address, std::string> _refresh_tokens;
134 absl::flat_hash_map<evmc::address, std::string> _access_tokens;
139struct std::formatter<
dcn::AuthenticationError> : std::formatter<std::string> {
151 default:
return formatter<string>::format(
"Unknown", ctx);
153 return formatter<string>::format(
"", ctx);
asio::awaitable< std::string > generateNonce(const evmc::address &address)
Definition auth.cpp:140
asio::awaitable< bool > verifyNonce(const evmc::address &address, const std::string &nonce)
Definition auth.cpp:150
asio::awaitable< std::string > generateAccessToken(const evmc::address &address)
Definition auth.cpp:211
asio::awaitable< bool > verifySignature(const evmc::address &address, const std::string &signature, const std::string &message)
Definition auth.cpp:169
asio::awaitable< bool > compareAccessToken(const evmc::address &address, std::string token) const
Definition auth.cpp:271
AuthManager & operator=(const AuthManager &)=delete
asio::awaitable< std::expected< evmc::address, AuthenticationError > > verifyAccessToken(std::string token) const
Definition auth.cpp:228
asio::awaitable< std::string > generateRefreshToken(const evmc::address &address)
Definition auth.cpp:288
AuthManager(const AuthManager &)=delete
asio::awaitable< std::expected< evmc::address, AuthenticationError > > verifyRefreshToken(std::string token) const
Definition auth.cpp:305
std::optional< std::string > parseAccessTokenFrom< http::Header::Authorization >(const std::string &header_str)
Definition auth.cpp:51
std::optional< std::string > parseRefreshTokenFrom< http::Header::XRefreshToken >(const std::string &header_str)
Definition auth.cpp:99
std::string parseAccessTokenTo< http::Header::SetCookie >(const std::string &token_str)
Definition auth.cpp:68
std::optional< std::string > parseRefreshTokenFrom< http::Header::Cookie >(const std::string &header_str)
Definition auth.cpp:83
std::string parseAccessTokenTo< http::Header::Authorization >(const std::string &token_str)
Definition auth.cpp:74
std::string parseNonceFromMessage(const std::string &msg)
Definition auth.cpp:17
std::string parseRefreshTokenTo(const std::string &token_str)
std::string parseRefreshTokenTo< http::Header::XRefreshToken >(const std::string &token_str)
Definition auth.cpp:123
std::string parseRefreshTokenTo< http::Header::SetCookie >(const std::string &token_str)
Definition auth.cpp:117
std::optional< std::string > parseRefreshTokenFrom(const std::string &header_str)
std::optional< std::string > parseAccessTokenFrom(const std::string &header_str)
std::optional< std::string > parseAccessTokenFrom< http::Header::Cookie >(const std::string &header_str)
Definition auth.cpp:35
std::string parseAccessTokenTo(const std::string &token_str)
Definition decentralised_art.hpp:30
AuthenticationError
Definition auth.hpp:86