nickjj / nickjj/docker-rails-example
Add Redis password
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 227
- PR merge metrics
- No merged PRs in 30d
Description
This is not an issue, but it would be nice to get people thinking about security by adding authentication to the Redis container. This can be done easily through the compose/.env files and minimal changes to the application, Redis, and Sidekiq configs.
.env.example:
#export REDIS_URL=redis://redis:6379/1
#export REDIS_PASSWORD=password
docker-compose.yml:
services:
redis:
command: >
--requirepass ${REDIS_PASSWORD:-password}
application.rb:
config.cache_store = :redis_cache_store, {
url: ENV.fetch("REDIS_URL") { "redis://redis:6379/1" },
namespace: "cache",
password: ENV.fetch("REDIS_PASSWORD") { "password" }
}
redis.rb:
@redis ||= Redis.new(url: ENV.fetch("REDIS_URL") { "redis://redis:6379/1" }, password: ENV.fetch("REDIS_PASSWORD") { "password" })
sidekiq.rb:
sidekiq_config = {
url: ENV.fetch("REDIS_URL") { "redis://redis:6379/1" },
password: ENV.fetch("REDIS_PASSWORD") { "password" }
}
cable.yml:
default: &default
password: "<%= ENV.fetch("REDIS_PASSWORD") { "password"} %>"
Even though ACLs are the preferred method for authentication in Redis 6+, best practice should probably be to use some form of authentication, even in development.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing .env.example and docker-compose.yml, then inspect application.rb, redis.rb, sidekiq.rb, and cable.yml. Trace how each component connects to Redis and verify that the shared REDIS_PASSWORD is applied consistently. Done means the Redis container requires authentication and the Rails cache, Redis client, Sidekiq, and Action Cable configurations all use it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, rails, redis, ruby
- Domain
- backend, databases, devops, security
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100