feat(secrets): updated as recommended in ashauthentication docs

This commit is contained in:
carla 2025-06-20 08:54:11 +02:00 committed by carla
parent 7bfde5e230
commit 565aaddd94
3 changed files with 35 additions and 10 deletions

26
lib/mv/secrets.ex Normal file
View file

@ -0,0 +1,26 @@
defmodule Mv.Secrets do
use AshAuthentication.Secret
def secret_for([:authentication, :strategies, :rauthy, :client_id], Mv.Accounts.User, _opts, _meth) do
get_config(:client_id)
end
def secret_for([:authentication, :strategies, :rauthy, :redirect_uri], Mv.Accounts.User, _opts, _meth) do
get_config(:redirect_uri)
end
def secret_for([:authentication, :strategies, :rauthy, :client_secret], Mv.Accounts.User, _opts, _meth) do
get_config(:client_secret)
end
def secret_for([:authentication, :strategies, :rauthy, :base_url], Mv.Accounts.User, _opts, _meth) do
get_config(:base_url)
end
defp get_config(key) do
:mv
|> Application.fetch_env!(:rauthy)
|> Keyword.fetch!(key)
|> then(&{:ok, &1})
end
end