omniauth_openid_connect
omniauth_openid_connect copied to clipboard
Dynamic client_options.redirect_uri value
There should be a way to have a dynamic value for the redirect_uri
value as the app hostname is not known at the configuration level.
The default OmniAuth
strategy uses the method callback_url
for example.
full_host + callback_path + query_string
Hey, Did you get any luck with this ?
Hey, Did you get any luck with this ?
@mazoonit yes, so i ended up just doing a monkey patch of the library with this :
module OmniAuth
module Strategies
# Override of the OpenIDConnect strategy to include the query string in the redirect_uri
class OpenIDConnect
# override of the redirect_uri method to include to dynamically detect the correct redirect_uri
def redirect_uri
callback_url
end
end
end
end
@Ksm125 Ended up doing the same yes to append custom state variable to the query string.
I used inheritance though because I used the plain OpenIDConnect
in another connections so I tended not to directly patch It but after all It's the same Idea 👨🏻💻
module OmniAuth
module Strategies
class Custom < OmniAuth::Strategies::OpenIDConnect
option :name, 'custom'
def new_state
state = if options.state.respond_to?(:call)
if options.state.arity == 1
options.state.call(env)
else
options.state.call
end
end
if request.params['state']
state = request.params['state']
end
session['omniauth.state'] = state || SecureRandom.hex(16)
end
end
end
end
Thanks 🚀