ontoportal / ontoportal-project

OntoPortal Alliance centralized repository for the management of the OntoPortal project
https://ontoportal.org/
3 stars 1 forks source link

Error in recaptcha initializer #35

Closed Bouchemel-Nasreddine closed 11 months ago

Bouchemel-Nasreddine commented 11 months ago

Hey, I activated the recaptcha in IndustryPortal ENV['USE_RECAPTCHA'] ||= 'true' ENV['RECAPTCHA_PUBLIC_KEY'] ||= 'pub_key' ENV['RECAPTCHA_PRIVATE_KEY'] ||= 'pri_key' i'm having this error in the ui:

App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:214: warning: previous definition of BUFSIZE was here App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:541: warning: previous definition of Socket was here App 19519 output: Error: The application encountered the following error: undefined method []' for nil:NilClass (NoMethodError) App 19519 output: /srv/ontoportal/bioportal_web_ui/releases/20220223134224/config/initializers/recaptcha.rb:3:inblock in <top (required)>' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/recaptcha-5.9.0/lib/recaptcha.rb:37:in configure' App 19519 output: /srv/ontoportal/bioportal_web_ui/releases/20220223134224/config/initializers/recaptcha.rb:2:in<top (required)>' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/engine.rb:667:in load' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/engine.rb:667:inblock in load_config_initializer' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/notifications.rb:208:in instrument' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/engine.rb:666:inload_config_initializer' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/engine.rb:620:in block (2 levels) in <class:Engine>' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/engine.rb:619:ineach' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/engine.rb:619:in block in <class:Engine>' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/initializable.rb:32:ininstance_exec' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/initializable.rb:32:in run' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/initializable.rb:61:inblock in run_initializers' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:228:in block in tsort_each' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:350:inblock (2 levels) in each_strongly_connected_component' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:422:in block (2 levels) in each_strongly_connected_component_from' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:431:ineach_strongly_connected_component_from' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:421:in block in each_strongly_connected_component_from' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/initializable.rb:50:ineach' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/initializable.rb:50:in tsort_each_child' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:415:incall' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:415:in each_strongly_connected_component_from' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:349:inblock in each_strongly_connected_component' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:347:in each' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:347:incall' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:347:in each_strongly_connected_component' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:226:intsort_each' App 19519 output: /usr/local/rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:205:in tsort_each' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/initializable.rb:60:inrun_initializers' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/railties-7.0.3/lib/rails/application.rb:372:in initialize!' App 19519 output: /srv/ontoportal/bioportal_web_ui/releases/20220223134224/config/environment.rb:5:in<top (required)>' App 19519 output: config.ru:3:in require_relative' App 19519 output: config.ru:3:inblock in

' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:125:in instance_eval' App 19519 output: /srv/ontoportal/.bundle/ruby/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:125:ininitialize' App 19519 output: config.ru:1:in new' App 19519 output: config.ru:1:in
' App 19519 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:101:in eval' App 19519 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:101:inpreload_app' App 19519 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in block in <module:App>' App 19519 output: /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:397:inrun_block_and_record_step_progress' App 19519 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in <module:App>' App 19519 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in' App 19519 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in <main>' [ E 2023-12-11 13:58:44.4303 15116/T16 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /srv/ontoportal/bioportal_web_ui/current: The application encountered the following error: undefined method[]' for nil:NilClass (NoMethodError) Error ID: 92f66bc0 Error details saved to: /tmp/passenger-error-vZEOSL.html [ E 2023-12-11 13:58:44.4350 15116/Tf age/Cor/Con/CheckoutSession.cpp:283 ]: [Client 4-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 92f66bc0. Please see earlier logs for details about the error.

the error happens at this line of code github , and seeing it I think I have to define site and secret key in config/credentials.yml.enc, is it right? if yes how to do that please?

Thanks

syphax-bouazzouni commented 11 months ago

Recaptch configuation were migrated to rails credentials, now you need to do rails credentials:edit and set

recaptcha:
       site_key: 
      secret_key: 
Bouchemel-Nasreddine commented 11 months ago

thanks @syphax-bouazzouni for your reply, for these two keys, are the ones found in config/master.yml and config/secrets.yml or are they defined somewhere else?

syphax-bouazzouni commented 11 months ago

Hello, it not related to config/master.ymlor config/secrets.yml.

what you need to do is:

  1. To go to your production server
  2. cd to /srv/ontoportal/bioportal_web_ui/current
  3. run this command RAILS_ENV=applaince EDITO='nano' bin/rails credentilals:edit , it will open an editor (linux nano in this case) , if it shows an error do this bundle config unset without && bundle config unset deployment && bundle install and try again
  4. fill in your recaptcha crendentials given by Google as so
    recaptcha:
       site_key:  <your site_key>
       secret_key:  <your_secret_key>
  5. restart using sudo oprestart

Some details can be found also here https://github.com/ontoportal-lirmm/bioportal_web_ui/issues/96

Tell me if it worked for you, and it will be great if you can create for us a documentation page for future people asking this. Do a PR here https://github.com/ontoportal/documentation/ so it can be displayed here https://ontoportal.github.io/documentation/developer

Bouchemel-Nasreddine commented 11 months ago

thanks @syphax-bouazzouni , no problem I will document this, but before that, well it did solve the initializing problem. However, the recaptcha in the website is saying the keys are invalid, "ERREUR pour le propriétaire du site: Type de clé non valid", I can see it was reported before in this issue ontoportal-lirmm/bioportal_web_ui/issues/95, but since the link to the fix is private I could not access it, if possible can you share the solution for it? thanks in advance

Bouchemel-Nasreddine commented 11 months ago

hey, apparently it didn't work when choosing v3 type (verification with score) of recpatcha at creation, now it works with type v2 (verification with challenge), thanks for your help @syphax-bouazzouni Screenshot from 2023-12-13 16-12-02