Skip to content

Commit

Permalink
Use trust auth for local development db container
Browse files Browse the repository at this point in the history
  • Loading branch information
svoop committed Mar 6, 2024
1 parent 255bb0d commit ba3f2e7
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ DEVELOPMENT_CREDENTIALS_KEY=...

The credentials are now available anywhere you inject them:

```
```ruby
module MyHanamiApp
class ApiKeyPrinter
include Deps[
Expand All @@ -220,6 +220,35 @@ module MyHanamiApp
end
```

You can use the credentials in other providers. Say, you want to pass the [ROM](https://rom-rb.org/) database URL (which contains the connection password) using credentials instead of settings. Simply replace `target["settings"].database_url` with `target["credentials"].database_url` and you're good to go:

```ruby
Hanami.app.register_provider :persistence, namespace: true do
prepare do
require "rom"

config = ROM::Configuration.new(:sql, target["credentials"].database_url)

register "config", config
register "db", config.gateways[:default].connection
end

(...)
end
```

Finally, if you have trouble using the credentials in slices, you might have to [share this app component](https://www.rubydoc.info/gems/hanami/Hanami/Config#shared_app_component_keys-instance_method) in `config/app.rb`:

```ruby
module MyHanamiApp
class App < Hanami::App
config.shared_app_component_keys += ["credentials"]
end
end
```

### Rails

### Rodbot

Dry::Credentials is integrated into [Rodbot](https://github.com/svoop/rodbot) out of the box, see [the README for more](https://github.com/svoop/rodbot/blob/main/README.md#credentials).
Expand Down

0 comments on commit ba3f2e7

Please sign in to comment.