Skip to content

Commit 1e7a49d

Browse files
Merge branch 'master' into closure-option
1 parent c8d33ca commit 1e7a49d

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

guides/how_to/rotate_keys.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ For example, if your config currently looks like this:
1515
default: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: <<...>>},
1616
]
1717

18-
Then change the `:default` label to the new key, and demote the existing
19-
key to the `:retired` label.
18+
Then you should change the `:default` label to the new key, and demote the
19+
existing key to the `:retired` label.
2020

2121
config :my_app, MyApp.Vault,
2222
ciphers: [
2323
default: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V2", key: <<...>>},
2424
retired: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: <<...>>}
2525
]
2626

27+
> #### Labels don't matter, order does {: .tip}
28+
>
29+
> The `:ciphers` configuration is _order-dependent_. The first key in the list
30+
> will be used as the default, regardless of its label. This guide uses the
31+
> `:default` and `:retired` labels for clarity, but the order is what matters.
32+
2733
## Migrate Data To New Key
2834

2935
For each schema that uses your vault, run `mix cloak.migrate`:

lib/cloak_ecto/type.ex

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ defmodule Cloak.Ecto.Type do
6868
def load(value) do
6969
with {:ok, value} <- decrypt(value) do
7070
value = after_decrypt(value)
71+
7172
if unquote(closure) do
7273
{:ok, fn -> value end}
7374
else

mix.exs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ defmodule Cloak.Ecto.MixProject do
7474
"guides/how_to/rotate_keys.md": [title: "Rotate Keys"],
7575
"guides/how_to/troubleshooting.md": [title: "Troubleshooting"],
7676
"guides/how_to/closure_wrapping.md": [title: "Closure Wrapping"],
77+
"guides/how_to/troubleshooting.md": [title: "Troubleshooting"],
7778
"guides/upgrading/0.9.x_to_1.0.x.md": [title: "0.9.x to 1.0.x"]
7879
],
7980
extra_section: "GUIDES",

test/cloak_ecto/types/date_test.exs

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ defmodule Cloak.Ecto.DateTest do
2727
test ".cast unwraps closures" do
2828
assert {:ok, ~D[2017-01-05]} = Field.cast(fn -> "2017-01-05" end)
2929
assert {:ok, ~D[2017-01-05]} = Field.cast(fn -> %{year: "2017", month: "1", day: "5"} end)
30-
assert {:ok, ~D[2017-01-05]} = Field.cast(fn -> %{"year" => "2017", "month" => "1", "day" => "5"} end)
30+
31+
assert {:ok, ~D[2017-01-05]} =
32+
Field.cast(fn -> %{"year" => "2017", "month" => "1", "day" => "5"} end)
33+
3134
assert {:ok, ~D[2017-01-05]} = Field.cast(fn -> ~D[2017-01-05] end)
3235
end
3336

@@ -48,5 +51,4 @@ defmodule Cloak.Ecto.DateTest do
4851
assert is_function(closure, 0)
4952
assert ~D[2017-01-05] = closure.()
5053
end
51-
5254
end

0 commit comments

Comments
 (0)