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

Extract function to refresh providers in Samly.Provider #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions lib/samly/provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule Samly.Provider do
store_opts = store_env[:opts] || []
State.init(store_provider, store_opts)

opts = Application.get_env(:samly, Samly.Provider, [])
opts = opts()

# must be done prior to loading the providers
idp_id_from =
Expand All @@ -56,6 +56,14 @@ defmodule Samly.Provider do
end

Application.put_env(:samly, :idp_id_from, idp_id_from)
refresh_providers()

{:ok, %{}}
end

@doc false
def refresh_providers do
opts = opts()

service_providers = Samly.SpData.load_providers(opts[:service_providers] || [])

Expand All @@ -64,7 +72,7 @@ defmodule Samly.Provider do

Application.put_env(:samly, :service_providers, service_providers)
Application.put_env(:samly, :identity_providers, identity_providers)

{:ok, %{}}
end

defp opts, do: Application.get_env(:samly, Samly.Provider, [])
end