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

Allow receiving raw XML metadadata with IDP config #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hodak
Copy link

@hodak hodak commented Dec 20, 2018

Hi, we have a case where we store IdPs in database, instead of config file. It allows us to store metadata with a db record.

@handnot2
Copy link
Owner

handnot2 commented Jan 2, 2019

Do you have the need to add IdP provider dynamically? There is an issue related to that: #29.

@hodak
Copy link
Author

hodak commented Jan 4, 2019

Yes, that is our use case

@handnot2
Copy link
Owner

I am planning to get to these PRs once the v1.0 release is out. Thanks for your patience.

@hodak
Copy link
Author

hodak commented Jan 31, 2019

No problem, at the time we're using fork. Thank you ;)

@hodak hodak force-pushed the raw-xml-in-config branch from 4a1cea8 to 3d883c8 Compare March 15, 2019 10:06
@hodak
Copy link
Author

hodak commented Mar 15, 2019

@handnot2 I have fixed conflicts with current master

@freevova
Copy link

freevova commented Jan 22, 2020

@hodak Great work. I would like to use this code too. @handnot2 Is it possible to merge this PR?

@messutied
Copy link

Hi @hodak, may I ask how do you use this for your use case? (load IdP from DB) do you use a completely separate flow? meaning that you do not use the provided Samly plugs, store, etc, and instead roll your own consumer action and use the underlaying modules of Samly there?

Looking into how to load IdP from DB myself :)

@hodak
Copy link
Author

hodak commented Feb 13, 2020

@messutied No, we pretty much use everything as-is, we just have a GenServer worker in our supervision tree (so it's called right after app boots), that does something like this:

  defp do_perform do
    idps =
      query_active_idps_from_db()
      |> Enum.map(fn idp ->
        Map.merge(default_opts, %{
          id: idp.subdomain,
          metadata: idp.metadata_xml,
          sp_id: idp.entity_id
        })
      end)

    new_env =
      Application.get_env(:samly, Samly.Provider, []) |> Keyword.put(:identity_providers, idps)

    Application.put_env(:samly, Samly.Provider, new_env)
    Samly.Provider.refresh_providers()
  end

and we have a way to trigger this refresh after identity provider changes in the database.

Remember that if you have multiple nodes, you must call the refresh on each one of them. This PR is also relevant: #38

@messutied
Copy link

Thanks a lot @hodak! very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants