-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Enhanced redis security: ACL and TLS #17577
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
user admin on +@all -DEBUG ~* >${USER_COUNTER_PASSWORD} | ||
user monitor on +hgetall +keys +select +get +mget +hget -DEBUG ~* >${MONITOR_PASSWORD} | ||
user default off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
# from redis official repo https://github.com/redis/redis/ | ||
# Generate some test certificates which are used by the regression test suite: | ||
# | ||
# certs/tls/ca.{crt,key} Self signed CA certificate. | ||
# certs/tls/redis.{crt,key} A certificate with no key usage/policy restrictions. | ||
|
||
generate_cert() { | ||
local name=$1 | ||
local cn="$2" | ||
local opts="$3" | ||
|
||
local keyfile=certs/tls/${name}.key | ||
local certfile=certs/tls/${name}.crt | ||
|
||
[ -f $keyfile ] || openssl genrsa -out $keyfile 2048 | ||
openssl req \ | ||
-new -sha256 \ | ||
-subj "/O=Redis Test/CN=$cn" \ | ||
-key $keyfile | \ | ||
openssl x509 \ | ||
-req -sha256 \ | ||
-CA certs/tls/ca.crt \ | ||
-CAkey certs/tls/ca.key \ | ||
-CAserial certs/tls/ca.txt \ | ||
-CAcreateserial \ | ||
-days 365 \ | ||
$opts \ | ||
-out $certfile | ||
} | ||
|
||
mkdir -p certs/tls | ||
[ -f certs/tls/ca.key ] || openssl genrsa -out certs/tls/ca.key 4096 | ||
openssl req \ | ||
-x509 -new -nodes -sha256 \ | ||
-key certs/tls/ca.key \ | ||
-days 3650 \ | ||
-subj '/O=Redis Test/CN=Certificate Authority' \ | ||
-out certs/tls/ca.crt | ||
|
||
cat > certs/tls/openssl.cnf <<_END_ | ||
[ server_cert ] | ||
keyUsage = digitalSignature, keyEncipherment | ||
nsCertType = server | ||
|
||
[ client_cert ] | ||
keyUsage = digitalSignature, keyEncipherment | ||
nsCertType = client | ||
_END_ | ||
|
||
generate_cert redis "Generic-cert" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
SPATH := $($(LIBHIREDIS)_SRC_PATH) | ||
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/hiredis.mk rules/hiredis.dep | ||
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) | ||
DEP_FILES += $(shell git ls-files $(SPATH)) | ||
|
||
$(LIBHIREDIS)_CACHE_MODE := GIT_CONTENT_SHA | ||
$(LIBHIREDIS)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) | ||
$(LIBHIREDIS)_DEP_FILES := $(DEP_FILES) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# libhiredis package | ||
|
||
HIREDIS_VERSION = 1.2.0 | ||
HIREDIS_VERSION_FULL = ${HIREDIS_VERSION}-4 | ||
|
||
export HIREDIS_VERSION HIREDIS_VERSION_FULL | ||
|
||
LIBHIREDIS = libhiredis1.1.0_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb | ||
$(LIBHIREDIS)_SRC_PATH = $(SRC_PATH)/hiredis | ||
SONIC_MAKE_DEBS += $(LIBHIREDIS) | ||
|
||
LIBHIREDIS_DEV = libhiredis-dev_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb | ||
$(eval $(call add_derived_package,$(LIBHIREDIS),$(LIBHIREDIS_DEV))) | ||
|
||
LIBHIREDIS_DBG = libhiredis1.1.0-dbgsym_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb | ||
$(eval $(call add_derived_package,$(LIBHIREDIS),$(LIBHIREDIS_DBG))) | ||
|
||
export LIBHIREDIS LIBHIREDIS_DEV LIBHIREDIS_DBG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The CA cert need protect by file permission? for example only RW/Admin user can modify it?
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.
It's a nice addition, but currently we generated a cert just to have TLS working.
We tried performing the TLS without a certificate but did not manage to do so.
I think that adding some write protect (for admin only) is possible in this case.
@davidpil2002 - please review it :)
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.
yes - the file was copied to the filesystem with the owner
admin
,the code can be seen in this PR in the filename
files/build_templates/sonic_debian_extension.j2