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

Support for customized tenant provider #451

Open
bschrag opened this issue Dec 5, 2023 · 1 comment
Open

Support for customized tenant provider #451

bschrag opened this issue Dec 5, 2023 · 1 comment

Comments

@bschrag
Copy link

bschrag commented Dec 5, 2023

Hello,

I am working on a project that needs to allow for organizations to configure their own google oauth integration for SSO. Looking through documentation and code, it didn't seem that this is yet supported out of the box. I was able to achieve it with a simple module and including it into OmniAuth::Strategies::GoogeOauth2 in my devise.rb initializer prior to loading it:

# config/initializers/devise.rb
module GoogleOmniAuthProviderCustomization
  def self.included(klass)
    klass.option :tenant_provider, nil
  end

  def client
    provider = if options.tenant_provider.class.is_a?(Class)
      options.tenant_provider.new(self)
    else
      options
    end
    options.client_id = provider.client_id
    options.client_secret = provider.client_secret

    super
  end
end

OmniAuth::Strategies::GoogleOauth2.include(GoogleOmniAuthProviderCustomization)


Devise.setup do |config|
  ...

  config.omniauth :google_oatuh2, tenant_provider: MyCustomGoogleProvider

  ...
end

If this is something that you feel would be of value I'm happy to submit a PR to extend the current functionality. Thanks for your time.

@zquestz
Copy link
Owner

zquestz commented Sep 16, 2024

Can you provide the code you put in MyCustomGoogleProvider?

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

2 participants