blob: 58766b99b3b5c848ec2612039c76c903215a5aff [file] [log] [blame]
Ed Tanousf9273472017-02-28 16:05:13 -08001#pragma once
2
3#include <crow/http_request.h>
4#include <crow/http_response.h>
5
Ed Tanous99923322017-03-03 14:21:24 -08006namespace crow {
Ed Tanousb4d29f42017-03-24 16:39:25 -07007
8struct User {
9
10};
11
Ed Tanous99923322017-03-03 14:21:24 -080012struct TokenAuthorizationMiddleware {
Ed Tanousb4d29f42017-03-24 16:39:25 -070013 // TODO(ed) auth_token shouldn't really be passed to the context
14 // it opens the possibility of exposure by and endpoint.
15 // instead we should only pass some kind of "user" struct
Ed Tanous99923322017-03-03 14:21:24 -080016 struct context {
Ed Tanousc4771fb2017-03-13 13:39:49 -070017 std::string auth_token;
Ed Tanous99923322017-03-03 14:21:24 -080018 };
Ed Tanousf9273472017-02-28 16:05:13 -080019
Ed Tanous8041f312017-04-03 09:47:01 -070020 TokenAuthorizationMiddleware();
Ed Tanousc4771fb2017-03-13 13:39:49 -070021
Ed Tanous99923322017-03-03 14:21:24 -080022 void before_handle(crow::request& req, response& res, context& ctx);
Ed Tanousf9273472017-02-28 16:05:13 -080023
Ed Tanous99923322017-03-03 14:21:24 -080024 void after_handle(request& req, response& res, context& ctx);
Ed Tanous8041f312017-04-03 09:47:01 -070025
26 private:
27 std::string auth_token2;
Ed Tanous99923322017-03-03 14:21:24 -080028};
Ed Tanousf9273472017-02-28 16:05:13 -080029}