blob: 214fd93ab6ae6ce1fa80d1f381c5fcd4796af67e [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>
Ed Tanous4758d5b2017-06-06 15:28:13 -07005#include <boost/container/flat_set.hpp>
Ed Tanousf9273472017-02-28 16:05:13 -08006
Ed Tanous99923322017-03-03 14:21:24 -08007namespace crow {
Ed Tanousb4d29f42017-03-24 16:39:25 -07008
Ed Tanous1ff48782017-04-18 12:45:08 -07009struct User {};
Ed Tanousb4d29f42017-03-24 16:39:25 -070010
Ed Tanous99923322017-03-03 14:21:24 -080011struct TokenAuthorizationMiddleware {
Ed Tanousb4d29f42017-03-24 16:39:25 -070012 // TODO(ed) auth_token shouldn't really be passed to the context
13 // it opens the possibility of exposure by and endpoint.
14 // instead we should only pass some kind of "user" struct
Ed Tanous99923322017-03-03 14:21:24 -080015 struct context {
Ed Tanous4758d5b2017-06-06 15:28:13 -070016 //std::string auth_token;
Ed Tanous99923322017-03-03 14:21:24 -080017 };
Ed Tanousf9273472017-02-28 16:05:13 -080018
Ed Tanous8041f312017-04-03 09:47:01 -070019 TokenAuthorizationMiddleware();
Ed Tanousc4771fb2017-03-13 13:39:49 -070020
Ed Tanous99923322017-03-03 14:21:24 -080021 void before_handle(crow::request& req, response& res, context& ctx);
Ed Tanousf9273472017-02-28 16:05:13 -080022
Ed Tanous99923322017-03-03 14:21:24 -080023 void after_handle(request& req, response& res, context& ctx);
Ed Tanous8041f312017-04-03 09:47:01 -070024
Ed Tanous1ff48782017-04-18 12:45:08 -070025 private:
Ed Tanous4758d5b2017-06-06 15:28:13 -070026 boost::container::flat_set<std::string> auth_token2;
Ed Tanous99923322017-03-03 14:21:24 -080027};
Ed Tanousf9273472017-02-28 16:05:13 -080028}