-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Basic_auth: Add bcrypt support #36882
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,17 @@ REPOSITORY_LOCATIONS_SPEC = dict( | |
release_date = "2022-06-13", | ||
cpe = "cpe:2.3:a:google:boringssl:*", | ||
), | ||
com_github_bcrypt = dict( | ||
project_name = "bcrypt", | ||
project_desc = " C++ wrapper around bcrypt password hashing", | ||
project_url = "https://github.com/hilch/Bcrypt.cpp", | ||
version = "V2.0_NODEBCRYPT", | ||
sha256 = "150abb95058a459e58f2bf995fd85af1d616374cc920d1ebb84666a8b2b3c50c", | ||
urls = ["https://github.com/hilch/Bcrypt.cpp/archive/refs/tags/{version}.tar.gz"], | ||
use_category = ["controlplane", "dataplane_core"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
release_date = "2021-12-24", | ||
cpe = "N/A", | ||
), | ||
Comment on lines
+166
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Poor OSSF Scorecard score:
|
||
aspect_bazel_lib = dict( | ||
project_name = "Aspect Bazel helpers", | ||
project_desc = "Base Starlark libraries and basic Bazel rules which are useful for constructing rulesets and BUILD files", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ envoy_cc_library( | |
name = "basic_auth_lib", | ||
srcs = ["basic_auth_filter.cc"], | ||
hdrs = ["basic_auth_filter.h"], | ||
external_deps = ["ssl"], | ||
external_deps = ["ssl", "bcrypt"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its not an external dep as defined here - i needs to be referenced as a normal dep using its There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @phlax for sharing, will do it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to add - you will most likely need to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
deps = [ | ||
"//envoy/server:filter_config_interface", | ||
"//source/common/common:base64_lib", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
#include "source/common/http/header_utility.h" | ||
#include "source/common/http/headers.h" | ||
#include "source/common/http/utility.h" | ||
#include <bcrypt/BCrypt.hpp> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer |
||
|
||
namespace Envoy { | ||
namespace Extensions { | ||
|
@@ -101,7 +102,12 @@ bool BasicAuthFilter::validateUser(const UserMap& users, absl::string_view usern | |
return false; | ||
} | ||
|
||
return computeSHA1(password) == user->second.hash; | ||
if (absl::StartsWith(user->second.hash, "{SHA}")) { | ||
return user->second.hash == absl::StrCat("{SHA}", computeSHA1(password)); | ||
} | ||
Comment on lines
+105
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid unnecessary string catting:
|
||
|
||
std::string password_string{password.data(), password.length()}; | ||
return BCrypt::validatePassword(password_string, user->second.hash); | ||
} | ||
|
||
Http::FilterHeadersStatus BasicAuthFilter::onDenied(absl::string_view body, | ||
|
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.
com_github_hilch_bcrypt