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

Document new caching behaviors #195

Merged
merged 2 commits into from
Nov 22, 2023
Merged
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
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,23 @@ config :prima_auth0_ex, :server,
missing_auth_header_log_level: :warn
```

### Redis & caching
## Caching

Clients can be configured to use caching through Redis. To use cachine you can use the following configuration:
Auth0_ex clients can cache tokens. By default the MemoryCache is used, which should allow tokens to be shared across erlang nodes. This behavior can be changed by setting `:prima_auth0_ex, :token_cache`

```elixir
# Disable caching of tokens
config :prima_auth0_ex, :token_cache, NoopCache
```

Note that right now caching is assumed to be all-or-nothing with respect to multiple clients i.e. either all clients use caching or none of them do. If you have a use case that is not supported by this please contact us so that we can see what we can do.

### Redis
Clients can be configured to use caching through Redis. To use caching you can use the following configuration:

```elixir
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,
Expand All @@ -117,9 +129,7 @@ config :prima_auth0_ex, :redis,
ssl_allow_wildcard_certificates: false
```

Note that right now caching is assumed to be all-or-nothing with respect to multiple clients i.e. either all clients use caching or none of them do. If you have a use case that is not supported by this please contact us so that we can see what we can do.

### Operational requirements
#### Operational requirements

To cache tokens on Redis you'll need to generate a `cache_encryption_key`. This can be done either by running `mix keygen` or by using the following snippet:

Expand Down