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

Protect redis access with username and password #192

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ to ~proxyOptionsEncoded~ using the key in ~SECRETS_KEY_FILE~.

When ~validateResponses~ is ~true~, responses are validated when
the request has an ~X-Validate-Response: true~ header.

*** OOAPI V4 & V5 configuration & validation

There are example configurations for handling and validating OOAPI v4
Expand Down Expand Up @@ -449,13 +450,23 @@ brew:
deployable docker image, including the configuration provided in the
[[./config][./config]] directory.

Ensure [[https://www.docker.com/][Docker]] is installed and do the usual
Ensure [[https://www.docker.com/][Docker]] is installed and do the usual:

#+begin_src sh
docker build .
#+end_src

To build the image
to build the image.

Use the following environment variables to setup the Redis username
and password in ~config/system.config.yml~:

- ~REDIS_USERNAME~
- ~REDIS_PASSWORD~

Note that not using authorization for Redis is also possible by
editing ~config/system.config.yml~ to delete the ~db.redis.username~
and ~db.redis.password~ properties before building the docker image.

** Location of system.config and gateway.config files and docker mounts

Expand Down
2 changes: 2 additions & 0 deletions config/system.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ db:
namespace: '${REDIS_NAMESPACE:-EG}'
host: '${REDIS_HOST:-redis}'
port: '${REDIS_PORT:-6379}'
username: '${REDIS_USERNAME}'
password: '${REDIS_PASSWORD}'

#plugins:
# express-gateway-plugin-example:
Expand Down
3 changes: 3 additions & 0 deletions test/config/redis.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
2 changes: 2 additions & 0 deletions test/config/redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user default off
user fred on +@all ~* >wilma
9 changes: 8 additions & 1 deletion test/integration.environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ module.exports = {
badBackend = require('../scripts/bad-backend').run(TEST_BAD_BACKEND_PORT)
slowBackend = require('../scripts/slow-backend').run(TEST_SLOW_BACKEND_PORT)

redis = await new GenericContainer('redis')
const redisImage = await GenericContainer
.fromDockerfile(path.resolve(__dirname, 'config'), 'redis.Dockerfile')
.build()

redis = await redisImage
.withName('redis')
.withWaitStrategy(Wait.forLogMessage('Ready to accept connections'))
.withExposedPorts(REDIS_PORT)
.start()
Expand Down Expand Up @@ -144,6 +149,8 @@ module.exports = {
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
REDIS_HOST,
REDIS_PORT: redisPort,
REDIS_USERNAME: 'fred',
REDIS_PASSWORD: 'wilma',
SECRETS_KEY_FILE: 'config/test-secret.txt'
})
.withWaitStrategy(Wait.forLogMessage('gateway http server listening'))
Expand Down
Loading