Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[34025] Allow insecure localhost redirect_uri for OAuth

Oliver Günther81bd0e34cd10
diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb
index aa3ce776980..a1ce5c022b6 100644
--- a/config/initializers/doorkeeper.rb
+++ b/config/initializers/doorkeeper.rb
@@ -124,7 +124,7 @@ Doorkeeper.configure do
#
# force_ssl_in_redirect_uri !Rails.env.development?
#
- # force_ssl_in_redirect_uri { |uri| uri.host != 'localhost' }
+ force_ssl_in_redirect_uri { |uri| uri.host != 'localhost' }
# Specify what redirect URI's you want to block during Application creation.
# Any redirect URI is whitelisted by default.
diff --git a/spec/features/admin/oauth/oauth_applications_management_spec.rb b/spec/features/admin/oauth/oauth_applications_management_spec.rb
index 4a41da232cc..06762105201 100644
--- a/spec/features/admin/oauth/oauth_applications_management_spec.rb
+++ b/spec/features/admin/oauth/oauth_applications_management_spec.rb
@@ -48,13 +48,15 @@ describe 'OAuth applications management', type: :feature, js: true do
click_on 'Create'
expect(page).to have_selector('.errorExplanation', text: 'Redirect URI must be an absolute URI.')
- fill_in 'application_redirect_uri', with: "urn:ietf:wg:oauth:2.0:oob\nhttps://localhost/my/callback"
+
+ # Can create localhost without https (https://community.openproject.com/wp/34025)
+ fill_in 'application_redirect_uri', with: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback"
click_on 'Create'
expect(page).to have_selector('.flash.notice', text: 'Successful creation.')
expect(page).to have_selector('.attributes-key-value--key', text: 'Client ID')
- expect(page).to have_selector('.attributes-key-value--value', text: "urn:ietf:wg:oauth:2.0:oob\nhttps://localhost/my/callback")
+ expect(page).to have_selector('.attributes-key-value--value', text: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback")
# Should print secret on initial visit
expect(page).to have_selector('.attributes-key-value--key', text: 'Client secret')