config: auto generate secret key if none given.

Automatically generate a random secret key for `Danbooru.config.secret_key_base`
if no key is specified.

This so that you can run Danbooru in a Docker container with zero
configuration.

This removes support for the ~/.danbooru/secret_token file and the
SECRET_TOKEN environment variable. If you used either one of these, you
must copy the value either to DANBOORU_SECRET_KEY_BASE in .env.local, or to
`secret_key_base` in config/danbooru_local_config.rb.

   # .env.local
   DANBOORU_SECRET_KEY_BASE=<value>

   # config/danbooru_local_config.rb
   def secret_key_base
      # <value>
   end
This commit is contained in:
evazion
2021-03-23 02:51:31 -05:00
parent 189adc683f
commit 1a8c70f5ff
4 changed files with 13 additions and 16 deletions

View File

@@ -34,8 +34,6 @@ RUN yarn install
COPY . .
RUN bundle config set path vendor/bundle --local
ARG DATABASE_URL=postgresql://0.0.0.0
ARG DANBOORU_SECRET_KEY_BASE=1234
ARG RAILS_ENV=production
RUN bin/rails assets:precompile && ln -sf packs public/packs-test
RUN rm -rf node_modules log tmp .yarn/cache && mkdir log tmp

View File

@@ -16,7 +16,6 @@ services:
- DATABASE_URL=postgresql://danbooru:danbooru@postgres/danbooru
- ARCHIVE_DATABASE_URL=postgresql://danbooru:danbooru@postgres/danbooru
- PARALLEL_WORKERS=8 # number of parallel tests to run
- DANBOORU_SECRET_KEY_BASE=1234
- DANBOORU_AWS_SQS_ENABLED
- DANBOORU_TWITTER_API_KEY
- DANBOORU_TWITTER_API_SECRET