Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 1 | #pragma once |
2 | |||||
3 | #include <crow/http_request.h> | ||||
4 | #include <crow/http_response.h> | ||||
Ed Tanous | 4758d5b | 2017-06-06 15:28:13 -0700 | [diff] [blame^] | 5 | #include <boost/container/flat_set.hpp> |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 6 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame] | 7 | namespace crow { |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 8 | |
Ed Tanous | 1ff4878 | 2017-04-18 12:45:08 -0700 | [diff] [blame] | 9 | struct User {}; |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 10 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame] | 11 | struct TokenAuthorizationMiddleware { |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 12 | // 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 Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame] | 15 | struct context { |
Ed Tanous | 4758d5b | 2017-06-06 15:28:13 -0700 | [diff] [blame^] | 16 | //std::string auth_token; |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame] | 17 | }; |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 18 | |
Ed Tanous | 8041f31 | 2017-04-03 09:47:01 -0700 | [diff] [blame] | 19 | TokenAuthorizationMiddleware(); |
Ed Tanous | c4771fb | 2017-03-13 13:39:49 -0700 | [diff] [blame] | 20 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame] | 21 | void before_handle(crow::request& req, response& res, context& ctx); |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 22 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame] | 23 | void after_handle(request& req, response& res, context& ctx); |
Ed Tanous | 8041f31 | 2017-04-03 09:47:01 -0700 | [diff] [blame] | 24 | |
Ed Tanous | 1ff4878 | 2017-04-18 12:45:08 -0700 | [diff] [blame] | 25 | private: |
Ed Tanous | 4758d5b | 2017-06-06 15:28:13 -0700 | [diff] [blame^] | 26 | boost::container::flat_set<std::string> auth_token2; |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame] | 27 | }; |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 28 | } |