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__
71 asio::awaitable<bool>
verifyNonce(
const evmc::address &
address,
const std::string & nonce);
77 asio::awaitable<std::expected<evmc::address, AuthenticationError>>
verifyAccessToken(std::string
token)
const;
86 asio::strand<asio::io_context::executor_type> _strand;
88 const std::string _SECRET;
91 std::uniform_int_distribution<int> _dist;
92 absl::flat_hash_map<evmc::address, std::string> _nonces;
94 absl::flat_hash_map<evmc::address, std::string> _refresh_tokens;
95 absl::flat_hash_map<evmc::address, std::string> _access_tokens;
100struct std::formatter<
dcn::AuthenticationError> : std::formatter<std::string> {
112 default:
return formatter<string>::format(
"Unknown", ctx);
114 return formatter<string>::format(
"", ctx);
asio::awaitable< std::string > generateNonce(const evmc::address &address)
Definition auth.cpp:88
asio::awaitable< bool > verifyNonce(const evmc::address &address, const std::string &nonce)
Definition auth.cpp:98
asio::awaitable< std::string > generateAccessToken(const evmc::address &address)
Definition auth.cpp:159
asio::awaitable< bool > verifySignature(const evmc::address &address, const std::string &signature, const std::string &message)
Definition auth.cpp:117
asio::awaitable< bool > compareAccessToken(const evmc::address &address, std::string token) const
Definition auth.cpp:219
AuthManager & operator=(const AuthManager &)=delete
asio::awaitable< std::expected< evmc::address, AuthenticationError > > verifyAccessToken(std::string token) const
Definition auth.cpp:176
asio::awaitable< std::string > generateRefreshToken(const evmc::address &address)
Definition auth.cpp:236
AuthManager(const AuthManager &)=delete
asio::awaitable< std::expected< evmc::address, AuthenticationError > > verifyRefreshToken(std::string token) const
Definition auth.cpp:253
std::string parseAccessTokenToCookieHeader(const std::string &token_str)
Definition auth.cpp:49
std::string parseRefreshTokenToCookieHeader(const std::string &token_str)
Definition auth.cpp:71
std::string parseNonceFromMessage(const std::string &msg)
Definition auth.cpp:17
std::optional< std::string > parseRefreshTokenFromCookieHeader(const std::string &cookie_str)
Definition auth.cpp:56
std::optional< std::string > parseAccessTokenFromCookieHeader(const std::string &cookie_str)
Definition auth.cpp:34
Definition decentralised_art.hpp:30
AuthenticationError
Definition auth.hpp:47