You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/service/auth.hpp

40 lines
889 B
C++

#pragma once
#include <optional>
#include <string>
#include <funcional>
#include "address.hpp"
#include "handler.hpp"
namespace llarp::service
{
/// authentication status
enum class AuthResult
{
/// explicitly accepted
eAuthAccepted,
/// explicitly rejected
eAuthRejected,
/// attempt failed
eAuthFailed,
/// attempt rate limited
eAuthRateLimit,
/// need mo munny
eAuthPaymentRequired
};
/// maybe get auth result from string
std::optional<AuthResult>
ParseAuthResult(std::string data);
struct IAuthPolicy
{
~IAuthPolicy() = default;
/// asynchronously determine if we accept new convotag from remote service, call hook with
/// result later
virtual void
AuthenticateAsync(
service::Address from, service::ConvoTag tag, std::function<void(AuthResult)> hook) = 0;
};
} // namespace llarp::service