samly icon indicating copy to clipboard operation
samly copied to clipboard

Allow receiving raw XML metadadata with IDP config

Open hodak opened this issue 6 years ago • 9 comments

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.

hodak avatar Dec 20 '18 10:12 hodak

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

handnot2 avatar Jan 02 '19 23:01 handnot2

Yes, that is our use case

hodak avatar Jan 04 '19 09:01 hodak

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

handnot2 avatar Jan 30 '19 19:01 handnot2

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

hodak avatar Jan 31 '19 06:01 hodak

@handnot2 I have fixed conflicts with current master

hodak avatar Mar 15 '19 12:03 hodak

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

freevova avatar Jan 22 '20 13:01 freevova

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 :)

messutied avatar Feb 12 '20 17:02 messutied

@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: https://github.com/handnot2/samly/pull/38

hodak avatar Feb 13 '20 07:02 hodak

Thanks a lot @hodak! very helpful.

messutied avatar Feb 13 '20 18:02 messutied