-
Couldn't load subscription status.
- Fork 96
Cache basic authentications #32
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
Conversation
|
If the general approach is fine I will add specific tests. |
51efd36 to
cec006b
Compare
5f139e5 to
75ce0a4
Compare
In order to improve the response time with basic authentication, cache the results of bcrypt in memory. This is a draft to see if that approach would be acceptable. The code is coming from Caddy, and I have fullfiled the attribution required by Apache-2 by adding the copyright to our headers: caddyserver/caddy@9a7756c Signed-off-by: Julien Pivotto <[email protected]>
75ce0a4 to
817d7e4
Compare
|
is this good to go? |
|
Hold on. |
Add getters and setters Add a lock around bcrypt Fix the unhappy scenario Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
|
OK now it works as expected. I have added getters and setters to release locks early. I have also added a Lock around bcrypt so that we only run one at the same time. |
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.
LGTM
| logger log.Logger | ||
| cache *cache | ||
| // bcryptMtx is there to ensure that bcrypt.CompareHashAndPassword is run | ||
| // only once in parallel as this is CPU expansive. |
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.
expansive → intensive?
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.
🤦🏻 I will fix it
In order to improve the response time with basic authentication, cache
the results of bcrypt in memory.
This is a draft to see if that approach would be acceptable.
The code is coming from Caddy, and I have fullfiled the attribution
required by Apache-2 by adding the copyright to our headers:
caddyserver/caddy@9a7756c
Signed-off-by: Julien Pivotto [email protected]