feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
// Outbound auth providers: Basic, Bearer, ApiKey, plus a custom base.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "clients/request.h"
|
||||
|
||||
namespace molo::clients {
|
||||
|
||||
class Auth {
|
||||
public:
|
||||
virtual ~Auth() = default;
|
||||
virtual void apply(ClientRequest& request) const = 0;
|
||||
virtual const char* scheme() const = 0;
|
||||
};
|
||||
|
||||
class BasicAuth : public Auth {
|
||||
public:
|
||||
BasicAuth(std::string username, std::string password);
|
||||
void apply(ClientRequest& request) const override;
|
||||
const char* scheme() const override { return "basic"; }
|
||||
|
||||
private:
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
};
|
||||
|
||||
class BearerAuth : public Auth {
|
||||
public:
|
||||
explicit BearerAuth(std::string token);
|
||||
void apply(ClientRequest& request) const override;
|
||||
const char* scheme() const override { return "bearer"; }
|
||||
|
||||
private:
|
||||
std::string token_;
|
||||
};
|
||||
|
||||
class ApiKeyAuth : public Auth {
|
||||
public:
|
||||
// Places the key in a header (default "X-Api-Key") or, when query_param is
|
||||
// set, in the URL query string instead.
|
||||
ApiKeyAuth(std::string key, std::string header = "X-Api-Key",
|
||||
std::string query_param = "");
|
||||
void apply(ClientRequest& request) const override;
|
||||
const char* scheme() const override { return "apikey"; }
|
||||
|
||||
private:
|
||||
std::string key_;
|
||||
std::string header_;
|
||||
std::string query_param_;
|
||||
};
|
||||
|
||||
std::string base64_encode(const std::string& input);
|
||||
|
||||
} // namespace molo::clients
|
||||
Reference in New Issue
Block a user