-
Notifications
You must be signed in to change notification settings - Fork 31
feat: create a C++ sample plugin for HMAC cookie authorization. #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create a C++ sample plugin for HMAC cookie authorization. #117
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
| const auto path = getRequestHeader(":path")->toString(); | ||
| if (computeHmacSignature(path) != token.value()) { | ||
| const std::optional<std::pair<std::string, std::string>> payload_and_hash = | ||
| parseAuthorizationCookie(token.value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: can dereference using *token instead of token.value(), since has_value() has been checked earlier. *token is shorter and doesn't have behavior that depends on build mode (i.e. whether or not to throw an exception)
| FilterHeadersStatus onRequestHeaders(uint32_t headers, | ||
| bool end_of_stream) override { | ||
| const auto token = getTokenFromCookie(); | ||
| const std::optional<std::string> ip = getClientIp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice structuring of this method! The factoring of checks/parsing into helper methods make it very clear.
This plugin is a HMAC cookie authorization showcase.
Technically, this is performed by ensuring that the request has a valid HMAC cookie.
This examples contains only a C++ version.