Hanami::Settings::Stores
Password manager-backed settings stores for Hanami.
Pluggable stores that fetch secrets from password managers like 1Password and Bitwarden, for use with
Hanami::Settings.
Requirements
-
1Password CLI (
op) — required forOnePasswordStore -
Bitwarden CLI (
bw) — required forBitwardenStore
Installation
Using Gem.coop
Add to your Gemfile:
gem "hanami-settings-stores", source: "https://beta.gem.coop/@aaron"Using Rubygems
Add to your Gemfile:
gem "hanami-settings-stores", source: "https://rubygems.org"Usage
OnePasswordStore
# config/app.rb
require "hanami/settings/stores"
module MyApp
class App < Hanami::App
config.settings_store = Hanami::Settings::CompositeStore.new(
Hanami::Settings::EnvStore.new,
Hanami::Settings::OnePasswordStore.new(vault: "Production")
)
end
endFetch settings from 1Password items. Define mappings with op_setting in your settings class:
# config/settings.rb
module MyApp
class Settings < Hanami::Settings
# Looks up field "database_url" on item "MyApp"
op_setting :database_url, item: "MyApp", constructor: Types::String
# Looks up field "secret_key" on a different item
op_setting :api_key, item: "ExternalService", key: :secret_key, constructor: Types::String
# Regular settings still work — these come from ENV via the default store
setting :some_flag, default: false, constructor: Types::Params::Bool
end
endBitwardenStore
# config/app.rb
require "hanami/settings/stores"
module MyApp
class App < Hanami::App
config.settings_store = Hanami::Settings::CompositeStore.new(
Hanami::Settings::EnvStore.new,
Hanami::Settings::BitwardenStore.new
)
end
endFetch settings from Bitwarden items. Define mappings with bw_setting in your settings class:
# config/settings.rb
module MyApp
class Settings < Hanami::Settings
bw_setting :database_url, item: "MyApp", constructor: Types::String
bw_setting :api_key, item: "ExternalService", key: :secret_key, constructor: Types::String
setting :some_flag, default: false, constructor: Types::Params::Bool
end
endCompositeStore
Chain multiple stores with fallback resolution. The first store to return a value wins. Settings resolve from ENV first, falling back to a password manager store for anything not found.
Stores
| Store | Status |
|---|---|
CompositeStore |
Available |
OnePasswordStore |
Available |
BitwardenStore |
Available |
Development
bundle install
mise run spec
mise run ruby