Error: uninitialized constant OmniAuth::Strategies::KeycloakOpenId::MultiJson after gem update - ruby-on-rails

My pplication is running on Ruby 2.7 / Rails 5.2.4 on Windows 10 and SUSE (SLES 15.SP3).
It uses Devise for authentication, with omniauth-keycloak, which worked fine for several months.
This morning I had tu run "bundle update" for an unrelated subject. After this update, invoking the link to Keycloak remote server for authentication issues the following error:
DEBUG -- omniauth: (keycloakopenid) Going to get Keycloak configuration. URL: https://identity-a.manage.ch/realms/bfs-sis-a/.well-known/openid-configuration
E, [2022-07-19T08:57:43.384693 #13364] ERROR -- omniauth: (keycloakopenid) Authentication failure! uninitialized constant OmniAuth::Strategies::KeycloakOpenId::MultiJson: NameError, uninitialized constant OmniAuth::Strategies::KeycloakOpenId::MultiJson
Processing by Users::OmniauthCallbacksController#failure as HTML
And redirects to the sign-in page.
The OmniAuth::Strategies::KeycloakOpenId::MultiJson constant does not exist in the project indeed.
The closest constant OmniAuth::Strategies::KeycloakOpenId is used in the devise.rb initializer:
config.omniauth :keycloak_openid,
"BFS.SIS",
client_options: { base_url: '', site: Rails.application.credentials.integration[:authentication_url], realm: "bfs-sis-a" },
strategy_class: OmniAuth::Strategies::KeycloakOpenId
Installed gem versions are:
devise (4.8.1)
oauth2 (2.0.6)
omniauth (2.1.0)
omniauth-oauth2 (1.7.3)
omniauth-keycloak (1.4.2)
omniauth-rails_csrf_protection (1.0.1)
How could I solve this issue?

Related

NameError (uninitialized constant OAuth Did you mean? OAuth2)

I'm trying to use omniauth-linkedin-oauth2 on RoR 5.0.7.
gem 'devise'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-linkedin-oauth2'
but I got an error on production environment and I can not start rails apps. My local developing environment is no problem to run it.
The error on production.log is
NameError (uninitialized constant OAuth Did you mean? OAuth2)
if I replaced
gem 'omniauth-linkedin-oauth2'
to
gem 'omniauth-linkedin'
and bundle update then there is no errors and RoR is running.
My production environment is
Debian GNU/Linux 8.11 (jessie)
Apache/2.4.10 (Debian)
Phusion_Passenger/6.0.2
ruby 2.4.6p354
You need to clear the session data to remove the existing OAuth token data. You can't use both token types simultaneously.
Per your comment (leaving an answer in case someone else has this same problem) you need to run:
RAILS_ENV=production rake db:sessions:clear

Devise + Omniauth Facebook invalid credentials

When I try to log in with omniauth(facebook) I get Invalid credentials error in production but it works fine in local.
I already added the urls in Valid OAuth redirect URIs
The callbacks I get are
/auth/facebook/callback?code=....
CallbacksController#failure
The gems I have.
oauth2 (1.2.0)
omniauth (1.3.1)
omniauth-facebook (4.0.0)
omniauth-oauth2 (1.4.0)
The solution was removing my IP from Server IP Whitelist
OAuth Error: This IP can't make requests for that application

environment variables in .bashrc not being set

I'm using a Rails app with Devise (for authentication) and the omniauth gem on a remote server. When I used to deploy to Heroku, I could set environment variables in the terminal, but that's not offered on the remote server I'm using. I therefore added the following to the bottom of .bashrc
export TWITTER_KEY="LxAuQ1Chmas;dlfkjdsal;fjds" TWITTER_SECRET="CC2XpLOeMJbvYphlafsdlkfjdsalkfj"
hoping that would set the environment variables configured in the Devise.rb file
config.omniauth :twitter, ENV["TWITTER_KEY"], ENV["TWITTER_SECRET"]
However, when I try to sign in with Twitter, I'm getting this
OAuth::Unauthorized (401 Unauthorized):
oauth (0.4.7) lib/oauth/consumer.rb:216:in `token_request'
oauth (0.4.7) lib/oauth/consumer.rb:136:in `get_request_token'
omniauth-oauth (1.0.1) lib/omniauth/strategies/oauth.rb:29:in `request_phase'
omniauth-twitter (1.0.0) lib/omniauth/strategies/twitter.rb:63:in `request_phase'
omniauth (1.1.4) lib/omniauth/strategy.rb:214:in `request_call'
so I'm assuming the environment variables aren't be read correctly. Can you explain another way I might set them?
I would suggest managing environment variables with the figaro gem.
Put environment variables in the yaml configuration file and they will be available in ENV.
It also provides a helpful rake task to set the variables on Heroku.

Facebook Authentication gets stuck in Production - using Rails 2.3.11 omniauth 1.0.2 in EC2

For my Rails 2.3.11 app, I've Omniauth based facebook authentication working in my development environment- Ubuntu box. That works perfectly. However in production it just sits there.
Ultimately I believe it fails because of timeout. I believe its failing in handling the callback from facebook: =">http://ziptrips.in:8002/auth/facebook/callback?code=AQA7cFWwM4Yrvm3dlREWv8-sdassasadas-9xkDVptqLfsl1Bevb9w8dbbcl9sgCmYugkWycgbFjqxWZozuiLAOzAJ1WxAde8T2DpRpJmYBXSNT4NtgGOup2O2XDmiYlEzAGSePEMeMjqvRX2oUCqHw#=
Since mine is a Rails 2.3.11 app, here's how my omniauth.rb in initializers looks like:
ActionController::Dispatcher.middleware.use OmniAuth::Builder do #if you are using rails 2.3.x
provider :facebook, '1234123343', '6aec22dssadsaetcetc', :client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}, :scope => 'email,offline_access,read_stream'
end
Here's relevant info:
Omniauth Gem : 1.0.2
omniauth-facebook gem: 1.2.0
Hosted in EC2
You can try it here: http://ziptrips.in/auth/facebook
I've made sure that facebook settings are correct.
Any help / pointers are really appreciated.
Thanks,
Navneet

Authlogic OpenID error: uninitialized constant OpenIdAuthentication::InvalidOpenId

Using authlogic 2.1.3, and authlogic-oid 1.0.4 I receive the following error as soon as rails hits a controller making a request to an OpenID provider:
uninitialized constant OpenIdAuthentication::InvalidOpenId
I also have the following installed:
rack-openid (0.2.1)
ruby-openid (2.1.7)
rails/open_id_authentication plugin
Gems in environment.rb are configured as such:
config.gem "authlogic"
config.gem "authlogic-oid", :lib => "authlogic_openid"
config.gem "ruby-openid", :lib => "openid"
Any suggestions would be appreciated, thank you.
rails/open_id_authentication plugin has been updated a few days ago and it breaks compatibility with the authlogic_openid gem (v=1.0.4).
Youl'll have to wait until someone fix the authlogic_openid gem (the issue)
I resolved that issue in my authlogic_openid fork, feel free to grab this commit: http://github.com/mreinsch/authlogic_openid/commit/9b802c347f5addebcbce945af3b5f80b3ee7b214
I was having the same trouble and I really wanted open-id with authlogic, so I copied an old version of plugin from one of Ryan Bates' railscasts apps.
Here's the link git#github.com:senthilnambi/open-id.git. Install it like normally and you should be fine.
Hope this helps. :)
Just like senthil provided, but with no # at URL:
script/plugin install git://github.com/senthilnambi/open-id.git
Then I erase the old (plugin/gem) who does not work
Going through the railscast 170. Troubleshooting lead me here. I tried authlogic_openid fork from last poster (mreinsch). This thankfully corrected openid_identifier error long enough for the regular login system to work, but not openid.
It's giving me an name error on the save method as identified in the block. This is apparently used to allow openid to get me to login.
Error Dump:
NameError in User sessionsController#create
uninitialized constant Rack::OpenID
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
/Sites/authlogic_b/vendor/plugins/authlogic_openid/lib/authlogic_openid/session.rb:72:in `save'
/Sites/authlogic_b/app/controllers/user_sessions_controller.rb:8:in `create'

Resources