!vVcsnwMNPHhwWsmXST:matrix.org

📣 Support Devs

233 Members
technical staff here!10 Servers

Load older messages


SenderMessageTime
25 Apr 2024
@matiasba8:matrix.orgMatíDev changed their display name from Matías Bustos to MatíDev.15:14:29
@matiasba8:matrix.orgMatíDevThanks!15:18:03
@sergiomassa:sibnsk.net@sergiomassa:sibnsk.net removed their profile picture.20:42:57
@sergiomassa:sibnsk.net@sergiomassa:sibnsk.net left the room.21:06:08
27 Apr 2024
@ricocotam:matrix.orgAdrien PouyetRedacted or Malformed Event09:49:10
@ricocotam:matrix.orgAdrien Pouyet
In reply to @ricocotam:matrix.org

Hi, here is my gem for omniauth : https://github.com/Ricocotam/omniauth-wp_oauth/tree/main
It's a replica of what I did. It doesn't work probably, I need more documentation but most of the code is there. The only missing part is the site attribute within the Omniauth strategy. I guess it can be initialized using the usual initializer but I didn't test with this specific gem. Decidim project will be published in the following weeks but apart from the initializer and plugins I didn't do anything. And here is the initializer :

if Rails.application.secrets.dig(:omniauth, :wp_oauth).present?
  Rails.application.config.middleware.use OmniAuth::Builder do
    provider(
      :wp_oauth,
      setup: ->(env) {
          request = Rack::Request.new(env)
          organization = Decidim::Organization.find_by(host: request.host)
          provider_config = organization.enabled_omniauth_providers[:wp_oauth]
          env["omniauth.strategy"].options[:client_id] = provider_config[:client_id]
          env["omniauth.strategy"].options[:client_secret] = provider_config[:client_secret]
         # :site is defined in the actual gem I use for now. I'm planning a switch but I'd rather it to be working first from decidim side
        },
      scope: :basic
    )
  end
end

Note that I'm not a ruby dev and I perfectly don't understand what I do here.

So to come back at my issue, my provider works (I tested using Postman) and it fails on Decidim callback.

First there's this call on the provider :

https://www.myprovider.fr/oauth/authorize/?client_id=[client_id]&code_challenge=[some_code]&code_challenge_method=S256&redirect_uri=https%3A%2F%2Fmy.decidim.fr%2Fusers%2Fauth%2Fwp_oauth%2Fcallback%3Flocale%3Den&response_type=code&scope=basic&state=[some_state]

Then I have this call that is redirected because failing :

https://my.decidim.fr/users/auth/wp_oauth/callback?locale=en&code=[another_code]&state=[same_state]&iframe=break

The final query gives me the message Could not authenticate you from ProviderName because "Invalid credentials". but I use the right credentials. And if I actually go on the redirected URL I posted above, I get in the red part Could not authenticate you from ProviderName because "Csrf detected".

If possible I'd like to avoid giving away exact URLs because there's a lot of sensitive informations you could access. And the provider mechanism prevents doing a fake account. But if no choice I can provide by "live" direct messaging

I managed to success, I finally used plain oauth2 gem and it worked !
10:26:38
@ricocotam:matrix.orgAdrien PouyetBut next steps fails :(10:27:52
@ricocotam:matrix.orgAdrien Pouyet
In reply to @ricocotam:matrix.org

Hi, here is my gem for omniauth : https://github.com/Ricocotam/omniauth-wp_oauth/tree/main
It's a replica of what I did. It doesn't work probably, I need more documentation but most of the code is there. The only missing part is the site attribute within the Omniauth strategy. I guess it can be initialized using the usual initializer but I didn't test with this specific gem. Decidim project will be published in the following weeks but apart from the initializer and plugins I didn't do anything. And here is the initializer :

if Rails.application.secrets.dig(:omniauth, :wp_oauth).present?
  Rails.application.config.middleware.use OmniAuth::Builder do
    provider(
      :wp_oauth,
      setup: ->(env) {
          request = Rack::Request.new(env)
          organization = Decidim::Organization.find_by(host: request.host)
          provider_config = organization.enabled_omniauth_providers[:wp_oauth]
          env["omniauth.strategy"].options[:client_id] = provider_config[:client_id]
          env["omniauth.strategy"].options[:client_secret] = provider_config[:client_secret]
         # :site is defined in the actual gem I use for now. I'm planning a switch but I'd rather it to be working first from decidim side
        },
      scope: :basic
    )
  end
end

Note that I'm not a ruby dev and I perfectly don't understand what I do here.

So to come back at my issue, my provider works (I tested using Postman) and it fails on Decidim callback.

First there's this call on the provider :

https://www.myprovider.fr/oauth/authorize/?client_id=[client_id]&code_challenge=[some_code]&code_challenge_method=S256&redirect_uri=https%3A%2F%2Fmy.decidim.fr%2Fusers%2Fauth%2Fwp_oauth%2Fcallback%3Flocale%3Den&response_type=code&scope=basic&state=[some_state]

Then I have this call that is redirected because failing :

https://my.decidim.fr/users/auth/wp_oauth/callback?locale=en&code=[another_code]&state=[same_state]&iframe=break

The final query gives me the message Could not authenticate you from ProviderName because "Invalid credentials". but I use the right credentials. And if I actually go on the redirected URL I posted above, I get in the red part Could not authenticate you from ProviderName because "Csrf detected".

If possible I'd like to avoid giving away exact URLs because there's a lot of sensitive informations you could access. And the provider mechanism prevents doing a fake account. But if no choice I can provide by "live" direct messaging

* I managed to success, I finally used almost plain oauth2, just modifying client options and the callback_path
10:33:32
@ricocotam:matrix.orgAdrien Pouyet * But next step fails. When I click on "complete the profile" it shows green and nothing more. And if I try to reconnect I just get the same form10:38:39
2 May 2024
@sdelcroix:matrix.orgsdelcroixHi everyone :) I've just upgrade from 0.26.9 to 0.26.10 and I get this error : "Error: The application encountered the following error: No such file to load -- decidim/templates/admin/apply_questionnaire_template.rb (LoadError)" 13:15:03
@sdelcroix:matrix.orgsdelcroix * Hi everyone :) I've just upgrade from 0.26.9 to 0.26.10 and I get this error : "Error: The application encountered the following error: No such file to load -- decidim/templates/admin/apply\_questionnaire\_template.rb (LoadError)" when loading the home page. 13:15:45
@sdelcroix:matrix.orgsdelcroix * Hi everyone :) I've just upgrade from 0.26.9 to 0.26.10 and I get this error : "Error: The application encountered the following error: No such file to load -- decidim/templates/admin/apply_questionnaire_template.rb (LoadError)" when loading the home page. 13:16:07
@sdelcroix:matrix.orgsdelcroixI don't use the "Templates" module and this version was aimed to keep 0.26 working without needing to add decidim-templates to Gemfile 13:18:57
@alecslupu:matrix.orgAlexandru Emil Lupu sdelcroix: strangely enough i cannot find any reference to : apply_questionnaire_template in the source code ... can u provide more info? 13:23:29
@sdelcroix:matrix.orgsdelcroixyes I can provide the trace13:23:57
@sdelcroix:matrix.orgsdelcroixmaybe a bootsnap cache issue ?13:24:10
@sdelcroix:matrix.orgsdelcroixthe trace is ending with "/home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require': No such file to load -- decidim/templates/admin/apply_questionnaire_template.rb (LoadError)"13:24:30
@sdelcroix:matrix.orgsdelcroixHere is the trace when I run "RAILS_ENV=production rails c" :13:27:42
@sdelcroix:matrix.orgsdelcroix *

Here is the trace when I run "RAILS_ENV=production rails c" :

Traceback (most recent call last):
	55: from bin/rails:4:in `<main>'
	54: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	53: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	52: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/commands.rb:18:in `<main>'
	51: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/command.rb:46:in `invoke'
	50: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/command/base.rb:69:in `perform'
	49: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	48: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	47: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	46: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/commands/console/console_command.rb:101:in `perform'
	45: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
	44: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/command/actions.rb:28:in `require_environment!'
	43: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/application.rb:339:in `require_environment!'
	42: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:324:in `require'
	41: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:291:in `load_dependency'
	40: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:324:in `block in require'
	39: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
	38: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	37: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	36: from /data/decidim-apps/decidim-app_26/config/environment.rb:5:in `<main>'
	35: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/application.rb:363:in `initialize!'
	34: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/initializable.rb:60:in `run_initializers'
	33: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
	32: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
	31: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
	30: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:347:in `call'
	29: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:347:in `each'
	28: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
	27: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
	26: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	25: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
	24: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/initializable.rb:61:in `block in run_initializers'
	23: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/initializable.rb:32:in `run'
	22: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/initializable.rb:32:in `instance_exec'
	21: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/application/finisher.rb:123:in `block in <module:Finisher>'
	20: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/application/finisher.rb:123:in `each'
	19: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/engine.rb:356:in `eager_load!'
	18: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/engine.rb:477:in `eager_load!'
	17: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/engine.rb:477:in `each'
	16: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/engine.rb:480:in `block in eager_load!'
	15: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/engine.rb:480:in `each'
	14: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/railties-6.0.6.1/lib/rails/engine.rb:481:in `block (2 levels) in eager_load!'
	13: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:280:in `require_dependency'
	12: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:367:in `depend_on'
	11: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:394:in `require_or_load'
	10: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:40:in `load_interlock'
	 9: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
	 8: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
	 7: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
	 6: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:40:in `block in load_interlock'
	 5: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:416:in `block in require_or_load'
	 4: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:324:in `require'
	 3: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:291:in `load_dependency'
	 2: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/dependencies.rb:324:in `block in require'
	 1: from /home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/home/decidim/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require': No such file to load -- decidim/templates/admin/apply_questionnaire_template.rb (LoadError)
13:28:22
@alecslupu:matrix.orgAlexandru Emil Lupu TBH ... I would remove the cache ... something like bin/rails tmp:clear, stop spring ( spring stop ) and then retry ... 13:30:44
@sdelcroix:matrix.orgsdelcroix I've clear the cache with bin/rails tmp:clear , restart the app with passenger-config restart-app and nginx too. Same error :/ 13:36:49
@sdelcroix:matrix.orgsdelcroix * I've cleared the cache with bin/rails tmp:clear , restart the app with passenger-config restart-app and nginx too. Same error :/ 13:36:59
@sdelcroix:matrix.orgsdelcroixIt seems that "polyglot" gem is required by "deface" gem which is a "decidim-awesome" dependency13:43:07
@sdelcroix:matrix.orgsdelcroix based on my Gemfile.lock13:44:01
@sdelcroix:matrix.orgsdelcroix * based on my Gemfile.lock13:45:51
@alecslupu:matrix.orgAlexandru Emil Lupuwhat other decidim modules do you have installed ?13:46:08
@sdelcroix:matrix.orgsdelcroix
gem 'decidim-decidim_awesome', '~> 0.10.2'

gem "decidim-term_customizer", git: "https://github.com/mainio/decidim-module-term_customizer", branch: "release/0.26-stable"
13:46:56
@alecslupu:matrix.orgAlexandru Emil Lupu

sdelcroix: we usually do not support the 0.26 version anymore , yet :

  1. do u have a public repo that i could play with?
  2. is it hard for you to actually upgrade to 0.27 ?
13:49:16
@sdelcroix:matrix.orgsdelcroixYep I know that :) 1 is "no" (and I recently learn that is not respecting the AGPL so I have to discuss this with my colleague) and 2. is "planned but more important projects are on our roadmap" :/ 13:52:17
@sdelcroix:matrix.orgsdelcroix * Yep I know that :) 1 is "no" (and I recently learned that is not respecting the AGPL so I have to discuss this with my colleague to put the app online) and 2. is "planned but more important projects are on our roadmap" :/ 13:52:45

Show newer messages


Back to Room ListRoom Version: 6