Skip to content

am not able to setup the OmniAuth strategy  #37

Closed
@deepak

Description

@deepak

I am trying to setup like so:

AUTH0_SETUP = lambda do |env|
  req = Rack::Request.new(env)

  namespace = 'foobar.auth0.com'
  site = "https://#{namespace}"
  client_info_querystring = "..."

  env['omniauth.strategy'].options[:client_id] = 'some-id'
  env['omniauth.strategy'].options[:client_secret] = 'some-secret'
  env['omniauth.strategy'].options[:namespace] = namespace
  env['omniauth.strategy'].options[:provider_ignores_state] = { callback_path: "/auth/auth0/callback" }
  env['omniauth.strategy'].options[:client_options]
    .merge!(site: site,
      authorize_url: "#{site}/authorize?#{client_info_querystring}",
      token_url: "#{site}/oauth/token?#{client_info_querystring}",
      userinfo_url: "#{site}/userinfo")
end

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :auth0, setup: AUTH0_SETUP
end

but this does not work because OmniAuth::Strategies::Auth0::initialize depends on args
and has a check on argument

fail(ArgumentError.new("Received wrong number of arguments. #{args.inspect}")) if @options[: namespace].nil?

but in case of setup args will be [{setup: <Proc>}] and will not have the namespace it needs

other Omniauth strategies like facebook use the option class method to configure it
and do not use the initialize method

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions