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

Possible to send login_hint to okta? #8

Open
aharpervc opened this issue Aug 23, 2019 · 1 comment
Open

Possible to send login_hint to okta? #8

aharpervc opened this issue Aug 23, 2019 · 1 comment

Comments

@aharpervc
Copy link

Per this support question I found, Okta supports sending a username to their form by sending login_hint as a query string param with authorization requests.

Is that possible to do with this gem? Is there a way to send custom query string parameters?

@sw4d
Copy link

sw4d commented Aug 31, 2023

I found this issue wondering the same thing.

I looked over the omniauth-google-oauth2 gem which allows this functionality.
Check out this method

I updated my okta initializer to something like this to get the behavior I wanted:

# /initializer/okta.rb

class OmniAuth::Strategies::Okta < OmniAuth::Strategies::OAuth2
	option :authorize_options, %w(login_hint some other options)

	def authorize_params
		super.tap do |params|
			options[:authorize_options].each do |k|
				params[k] = request.params[k.to_s] unless [nil, '', []].include?(request.params[k.to_s])
			end
		end
	end
end


Rails.application.config.middleware.use OmniAuth::Builder do
  provider :okta, ENV['OKTA_CLIENT_ID'], ENV['OKTA_CLIENT_SECRET'], {
    client_options: {
      site:                 'https://your-org.okta.com',
      authorization_server: '<authorization_server>',
      authorize_url:        'https://your-org.okta.com/oauth2/<authorization_server>/v1/authorize',
      token_url:            'https://your-org.okta.com/oauth2/<authorization_server>/v1/token',
      user_info_url:        'https://your-org.okta.com/oauth2/<authorization_server>/v1/userinfo',
      audience:             'api://your-audience'
    }
  }
end

Hope that helps get the gears turning.

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