WIP: basic server, no features

This commit is contained in:
Aaron Kimbrell
2026-01-25 22:33:51 -06:00
parent c723ce2588
commit f1847d1f20
67 changed files with 7655 additions and 37 deletions

43
dWeb/AuthMiddleware.h Normal file
View File

@@ -0,0 +1,43 @@
#pragma once
#include "IHTTPMiddleware.h"
#include <vector>
/**
* Authentication Middleware
*
* Verifies JWT tokens from:
* - Query parameter: ?token=...
* - Cookie: dashboardToken=...
* - Authorization header: Bearer <token> or Token <token>
*
* Populates HTTPContext with authentication information if valid.
* Does NOT fail on missing auth - that's left to specific routes.
*/
class AuthMiddleware : public IHTTPMiddleware {
public:
AuthMiddleware() = default;
bool Process(HTTPContext& context, HTTPReply& reply) override;
std::string GetName() const override { return "AuthMiddleware"; }
private:
/**
* Extract token from query string
* Expected format: "?token=eyJhbGc..." or "&token=eyJhbGc..."
*/
static std::string ExtractTokenFromQueryString(const std::string& queryString);
/**
* Extract token from Cookie header
* Looks for "dashboardToken=..." cookie
*/
static std::string ExtractTokenFromCookies(const std::string& cookieHeader);
/**
* Extract token from Authorization header
* Supports: "Bearer <token>", "Token <token>", or raw token
*/
static std::string ExtractTokenFromAuthHeader(const std::string& authHeader);
};