File tree Expand file tree Collapse file tree 4 files changed +21
-12
lines changed
Expand file tree Collapse file tree 4 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## v2.3.1
4+
5+ * Change compile time loading of configuration to only load permissions
6+ allowing the app to change things like ttl or secret key at runtime
7+
38## v2.3.0
49
510* Fix warning about the usage of ` Application.get_env ` in the module scope
Original file line number Diff line number Diff line change @@ -340,16 +340,20 @@ defmodule Guardian do
340340 the_otp_app = unquote ( otp_app )
341341 the_opts = unquote ( opts )
342342
343- # Provide a way to get at the configuration during compile time
344- # for other macros that may want to use them
345- @ config fn ->
346- the_otp_app |> Application . compile_env ( __MODULE__ , [ ] ) |> Keyword . merge ( the_opts )
347- end
348- @ config_with_key fn key ->
349- @ config . ( ) |> Keyword . get ( key ) |> Guardian.Config . resolve_value ( )
350- end
351- @ config_with_key_and_default fn key , default ->
352- @ config . ( ) |> Keyword . get ( key , default ) |> Guardian.Config . resolve_value ( )
343+ # Provide a way to get at the permissions during compile time. Uses
344+ # permissions from config if they are available and falls back to the
345+ # permissins defined on the `use Guardian` implementation
346+ #
347+ # NOTE: Generally you can't use compile_env for most keys because that
348+ # would prevent people from changing them at runtime for differen
349+ # environements.And hardcoding secret keys wouldn't be considered a good
350+ # practice.
351+ @ config_permissions fn ->
352+ perms =
353+ Application . compile_env ( the_otp_app , [ __MODULE__ , :permissions ] ) ||
354+ Keyword . get ( the_opts , :permissions , [ ] )
355+
356+ Guardian.Config . resolve_value ( perms )
353357 end
354358
355359 @ doc """
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ defmodule Guardian.Permissions do
137137
138138 defdelegate max ( ) , to: Guardian.Permissions
139139
140- raw_perms = @ config_with_key . ( :permissions )
140+ raw_perms = @ config_permissions . ( )
141141
142142 unless raw_perms do
143143 raise "Permissions are not defined for #{ to_string ( __MODULE__ ) } "
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ defmodule Guardian.Mixfile do
22 @ moduledoc false
33 use Mix.Project
44
5- @ version "2.3.0 "
5+ @ version "2.3.1 "
66 @ url "https://github.com/ueberauth/guardian"
77 @ maintainers [
88 "Daniel Neighman" ,
You can’t perform that action at this time.
0 commit comments