Skip to content

Environment-specific credentials #31349

@mrsweaters

Description

@mrsweaters

Steps to reproduce

Run Rails.application.credentials from the console from any environment.

Expected behavior

Rails.application.secrets will return environment specific secrets from secrets.yml if they are name spaced by environment.

I would expect Rails.application.credentials to do the same. There are instances where data like third-party API keys are still unique to the loaded environment. It would be nice to be able to store these in the encrypted credentials as well.

Instead of having to do this:

Rails.application.credentials[Rails.env].my_credential

This is preferred:

Rails.application.credentials.my_credential

With a credentials file structured like this:

development:
  my_credential: token
test:
  my_credential: token
production:
  my_credential: token

Actual behavior

Rails.application.credentials returns all credentials at root level.

System configuration

Rails version: 5.2.0.beta2

Ruby version: 2.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions