Closed allanegidio closed 6 months ago
@allanegidio To do this, you'd need to define the :label
in the field definition:
defmodule MyApp.Encrypted.TwoFactorBinary do
use Cloak.Ecto.Binary, vault: MyApp.Vault, label: :two_factor_auth
end
Then use it in your field definition in your schema:
field(:two_factor_token, MyApp.Encrypted.TwoFactorBinary)
Hello.
I'm trying to implement the same thing that we have during config MyApp.Vault.
For example: I can have more than one cipher:
Keyword.put(config, :ciphers, [ default: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: decode_env!("MY_KEY")}, two_factor_auth: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: decode_env!("MY_SEC_KEY")} ])
If I use
MyApp.Vault.encrypt("test", :two_factor_auth)
I can choose which ciphers I want to use. Unfortunately, I couldn't do the same thing during config a field on my Ecto Schema.field(:two_factor_token, MyApp.Encrypted.Binary, label: :two_factor_auth)
There is this possibility? To choose which cipher my field should use?