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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add comma to authenticate header
Oliver Günther4a3dfcc74e44
diff --git a/lib_static/open_project/authentication.rb b/lib_static/open_project/authentication.rbindex b1d911e623d..d66e2d6b531 100644--- a/lib_static/open_project/authentication.rb+++ b/lib_static/open_project/authentication.rb@@ -270,8 +270,8 @@ module OpenProjectrequest_headers)header = %{#{scheme} realm="#{scope_realm(scope)}"}- header << %{ error="#{error}"} if error- header << %{ error_description="#{error_description}"} if error && error_description+ header << %{, error="#{error}"} if error+ header << %{, error_description="#{error_description}"} if error && error_descriptionheaderenddiff --git a/spec/requests/api/v3/authentication_spec.rb b/spec/requests/api/v3/authentication_spec.rbindex 7683cd98860..045177706b6 100644--- a/spec/requests/api/v3/authentication_spec.rb+++ b/spec/requests/api/v3/authentication_spec.rb@@ -65,7 +65,7 @@ RSpec.describe "API V3 Authentication" doit "returns unauthorized" doexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="invalid_token"')+ expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API", error="invalid_token"')expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -76,7 +76,7 @@ RSpec.describe "API V3 Authentication" doit "returns unauthorized" doexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="invalid_token"')+ expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API", error="invalid_token"')expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -93,7 +93,7 @@ RSpec.describe "API V3 Authentication" doit "returns unauthorized" doexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="invalid_token"')+ expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API", error="invalid_token"')expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -104,7 +104,7 @@ RSpec.describe "API V3 Authentication" doit "returns forbidden" doexpect(last_response).to have_http_status :forbidden- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="insufficient_scope"')+ expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API", error="insufficient_scope"')expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -120,7 +120,7 @@ RSpec.describe "API V3 Authentication" doit "returns unauthorized" doexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="invalid_token"')+ expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API", error="invalid_token"')expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -414,7 +414,8 @@ RSpec.describe "API V3 Authentication" doit doget resourceexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq("Bearer realm=\"OpenProject API\" error=\"invalid_token\" error_description=\"The access token issuer is unknown\"")+ expect(last_response.header["WWW-Authenticate"])+ .to eq(%{Bearer realm="OpenProject API", error="invalid_token", error_description="The access token issuer is unknown"})expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -422,13 +423,16 @@ RSpec.describe "API V3 Authentication" docontext "when token is issued by provider configured in OP" docontext "when token signature algorithm is not supported" dolet(:token) do- "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJpc3MiOiJodHRwczovL2tleWNsb2FrLmxvY2FsL3JlYWxtcy9tYXN0ZXIifQ.Pwod8ZJqq3jWsbnrGw4ZU1-aLS2bSicb8PgiF78JHUc"+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5" \+ "MDIyLCJpc3MiOiJodHRwczovL2tleWNsb2FrLmxvY2FsL3JlYWxtcy9tYXN0ZXIifQ.Pwod8ZJqq3jWsbnrGw4ZU1-aLS2bSicb8PgiF78JHUc"endit doget resourceexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq("Bearer realm=\"OpenProject API\" error=\"invalid_token\" error_description=\"Token signature algorithm is not supported\"")+ error = "Token signature algorithm is not supported"+ expect(last_response.header["WWW-Authenticate"])+ .to eq(%{Bearer realm="OpenProject API", error="invalid_token", error_description="#{error}"})expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -455,7 +459,9 @@ RSpec.describe "API V3 Authentication" doget resourceendexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="invalid_token" error_description="The access token audience claim is wrong"')+ error = "The access token audience claim is wrong"+ expect(last_response.header["WWW-Authenticate"])+ .to eq(%{Bearer realm="OpenProject API", error="invalid_token", error_description="#{error}"})expect(JSON.parse(last_response.body)).to eq(error_response_body)endend@@ -481,7 +487,8 @@ RSpec.describe "API V3 Authentication" doendexpect(last_response).to have_http_status :unauthorized- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="invalid_token" error_description="The access token expired"')+ expect(last_response.header["WWW-Authenticate"])+ .to eq(%{Bearer realm="OpenProject API", error="invalid_token", error_description="The access token expired"})expect(JSON.parse(last_response.body)).to eq(error_response_body)end@@ -521,7 +528,9 @@ RSpec.describe "API V3 Authentication" doendexpect(last_response).to have_http_status :unauthorizedexpect(JSON.parse(last_response.body)).to eq(error_response_body)- expect(last_response.header["WWW-Authenticate"]).to eq('Bearer realm="OpenProject API" error="invalid_token" error_description="The access token signature kid is unknown"')+ error = "The access token signature kid is unknown"+ expect(last_response.header["WWW-Authenticate"])+ .to eq(%{Bearer realm="OpenProject API", error="invalid_token", error_description="#{error}"})endendend