Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMSSE-730]: Fix docs and warning for redis cache config #204

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ Note that right now caching is assumed to be all-or-nothing with respect to mult
Clients can be configured to use caching through Redis. To use caching you can use the following configuration:

```elixir
# Enables cache on redis for tokens obtained from Auth0.
config :prima_auth0_ex, :token_cache, EncryptedRedisTokenCache

config :prima_auth0_ex, :redis,
# Enables cache on redis for tokens obtained from Auth0. Defaults to false.
enabled: true,
# AES 256 key used to encrypt tokens on the shared cache.
# Can be generated via `:crypto.strong_rand_bytes(32) |> Base.encode64()`.
encryption_key: "uhOrqKvUi9gHnmwr60P2E1hiCSD2dtXK1i6dqkU4RTA=",
Expand Down
20 changes: 15 additions & 5 deletions lib/prima_auth0_ex/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,34 @@ defmodule PrimaAuth0Ex.Application do

defp migrate_deprecated_cache_options do
redis_enabled = Config.redis(:enabled)
cache_provieder = Config.token_cache(nil)
cache_provider = Config.token_cache(nil)

case {redis_enabled, cache_provieder} do
case {redis_enabled, cache_provider} do
{nil, _} ->
nil

{true, nil} ->
Application.put_env(:prima_auth0_ex, :token_cache, EncryptedRedisTokenCache)

Logger.warning("""
The
:prima_auth0_ex, :redis, :enabled option
The
:prima_auth0_ex, :redis, :enabled option
is deprecated.
Set
:prima_auth0_ex, token_cache: EncryptedRedisTokenCache
:prima_auth0_ex, token_cache: EncryptedRedisTokenCache
instead
""")

{true, _} ->
Logger.warning("""
The
:prima_auth0_ex, :redis, :enabled option
is deprecated.
Setting
:prima_auth0_ex, token_cache: #{cache_provider}
alone is sufficient
""")

{false, nil} ->
Application.put_env(:prima_auth0_ex, :token_cache, NoopCache)

Expand Down
Loading