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

Improve performance, fix bug in authorization schema #168

Merged
merged 11 commits into from
Dec 28, 2023
Merged

Improve performance, fix bug in authorization schema #168

merged 11 commits into from
Dec 28, 2023

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Dec 28, 2023

While programming I realized we have a bug in the code. We did not check if between Bearerand key was atleast one space. This bug is fixed, see unit tests.

before:
Missing Header:

autocannon http://127.0.0.1:8000/foo
0 2xx responses, 271167 non 2xx responses
271k requests in 10.01s, 59.9 MB read

Invalid BearerType:

autocannon -H authorization='Beaver key' http://127.0.0.1:8000/foo
0 2xx responses, 295334 non 2xx responses
295k requests in 11.01s, 65.3 MB read

Invalid key:

autocannon -H authorization='Bearer invalid' http://127.0.0.1:8000/foo
0 2xx responses, 274488 non 2xx responses
274k requests in 11.01s, 60.7 MB read

Valid Request:

autocannon -H authorization='Bearer key' http://127.0.0.1:8000/foo
272k requests in 11.01s, 52.6 MB read

after:
Missing Header:

autocannon http://127.0.0.1:8000/foo
0 2xx responses, 300072 non 2xx responses
300k requests in 11.01s, 66.3 MB read

Invalid BearerType:

autocannon -H authorization='Beaver key' http://127.0.0.1:8000/foo
0 2xx responses, 291809 non 2xx responses
292k requests in 11.01s, 64.5 MB read

Invalid key:

autocannon -H authorization='Bearer invalid' http://127.0.0.1:8000/foo
0 2xx responses, 326559 non 2xx responses
327k requests in 11.01s, 72.2 MB read

Valid Request:

autocannon -H authorization='Bearer key' http://127.0.0.1:8000/foo
404k requests in 11.01s, 77.9 MB read

Checklist

@Uzlopak Uzlopak marked this pull request as ready for review December 28, 2023 01:57
@Uzlopak Uzlopak changed the title Improve performance Improve performance, fix bug in authorization schema Dec 28, 2023
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

Looks great!

@Eomm Eomm merged commit fb4b081 into master Dec 28, 2023
21 checks passed
@Eomm Eomm deleted the improve-B branch December 28, 2023 09:07
@olivierchatry
Copy link

I'm quite sure that BearerType should be case insensitive.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Dec 29, 2023

@olivierchatry

My PR did not change any behaviour regarding case sensitivity. Probably you wanted to comment it on PR #167 by @dancastillo , who changed bearer to Bearer.

Eitherway, maybe open an issue to discuss it.

@jsumners
Copy link
Member

I am quite certain the spec requires Bearer https://www.rfc-editor.org/rfc/rfc6750#section-2.1

@olivierchatry
Copy link

lexik/LexikJWTAuthenticationBundle#411

I think this is just a string comparaison, and there will most probably be bearer and Bearer in the wilde. This is really just string comparison, so I'm not sure why not do it.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Dec 30, 2023

@olivierchatry

Please open an issue and discuss this there. Please also refer also to RFCs. This PR did not change that behaviour as I already explained.

@fastify fastify locked as too heated and limited conversation to collaborators Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants