Skip to content
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: Add method to extract HTTP Bearer token from Authorisation header. #1258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mowijo
Copy link

@mowijo mowijo commented Oct 27, 2024

This PR Adds a method to extract HTTP Bearer token from the Authorisation header, thus closing #1257.

Copy link
Member

@kiplingw kiplingw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to bump the patch version in version.txt because you are adding new interfaces.

if (!hasMethod<Authorization::Method::Bearer>())
throw std::runtime_error("Authorization header does not use Bearer method.");

const std::string token(value_.begin() + std::string("Bearer ").length(), value_.end());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a problem. You need to make sure that there was a properly formatted token after Bearer . Otherwise you could end up with a scenario where the client sends a malformed request, perhaps intentionally, and it takes down the server.

Copy link

codecov bot commented Oct 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.31%. Comparing base (5144616) to head (f0c77a3).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1258      +/-   ##
==========================================
+ Coverage   75.60%   76.31%   +0.70%     
==========================================
  Files          56       57       +1     
  Lines        8733     9815    +1082     
==========================================
+ Hits         6603     7490     +887     
- Misses       2130     2325     +195     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants