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

Can't set strategy options at runtime #170

Open
alexgleason opened this issue Aug 14, 2022 · 2 comments
Open

Can't set strategy options at runtime #170

alexgleason opened this issue Aug 14, 2022 · 2 comments

Comments

@alexgleason
Copy link

Steps to Reproduce

  1. Configure a strategy at runtime, eg:
config :ueberauth, Ueberauth,
  providers: [
    keycloak: {Ueberauth.Strategy.Keycloak, [uid_field: :email, default_scope: "openid profile"]}
  ]
  1. Try to log in.
  2. The default_scope still uses the default from the strategy.

Expected Result

Calling Ueberauth.Strategy.Helpers.options/1 always returns the current options at runtime.

Actual Result

Strategy options are set at compile time and runtime configuration isn't respected.

@mustela
Copy link

mustela commented Nov 30, 2022

Having the same issue... has anyone have any tip to configure it in runtime? Thanks!

@grzuy
Copy link

grzuy commented May 25, 2023

It appears the issue is the providers: setting is read only in init/1, and normally phoenix/plug init_mode is :compile in production.

A workaround to make just ueberauth read settings at run-time is to write a plug wrapper (based on https://akoutmos.com/post/plug-runtime-config/):

defmodule YourApp.Ueberauth do
  @behaviour Plug

  @impl true
  def init(opts) do
    opts
  end

  @impl true
  def call(conn, opts) do
    conn
    |> Ueberauth.call(Ueberauth.init(opts))
  end
end

and in your Auth controller

  plug YourApp.Ueberauth

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

No branches or pull requests

3 participants