From 24fd70676c55b55cadf8fd345ab00269d3b7f852 Mon Sep 17 00:00:00 2001
From: theworldbright <kent@kentshikama.com>
Date: Fri, 7 Aug 2015 15:46:32 +0900
Subject: [PATCH] Fix webfinger discovery route

---
 app/controllers/api/openid_connect/discovery_controller.rb    | 2 +-
 config/routes.rb                                              | 4 ++--
 .../api/openid_connect/discovery_controller_spec.rb           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/controllers/api/openid_connect/discovery_controller.rb b/app/controllers/api/openid_connect/discovery_controller.rb
index 7c92ecbd79..df1cfec341 100644
--- a/app/controllers/api/openid_connect/discovery_controller.rb
+++ b/app/controllers/api/openid_connect/discovery_controller.rb
@@ -5,7 +5,7 @@ module Api
         jrd = {
           links: [{
             rel:  OpenIDConnect::Discovery::Provider::Issuer::REL_VALUE,
-            href: File.join(root_url, "api", "openid_connect")
+            href: root_url
           }]
         }
         jrd[:subject] = params[:resource] if params[:resource].present?
diff --git a/config/routes.rb b/config/routes.rb
index b38cd165ce..a925550387 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -247,13 +247,13 @@ Diaspora::Application.routes.draw do
       resources :authorizations, only: %i(new create destroy)
       post "authorizations/new", to: "authorizations#new"
 
-      get ".well-known/webfinger", to: "discovery#webfinger"
-      get ".well-known/openid-configuration", to: "discovery#configuration"
       get "jwks.json", to: "id_tokens#jwks"
 
       get "user_info", to: "user_info#show"
     end
   end
 
+  get ".well-known/webfinger", to: "api/openid_connect/discovery#webfinger"
+  get ".well-known/openid-configuration", to: "api/openid_connect/discovery#configuration"
   get "user_applications", to: "user_applications#index"
 end
diff --git a/spec/controllers/api/openid_connect/discovery_controller_spec.rb b/spec/controllers/api/openid_connect/discovery_controller_spec.rb
index 0233ae180a..77de08ea03 100644
--- a/spec/controllers/api/openid_connect/discovery_controller_spec.rb
+++ b/spec/controllers/api/openid_connect/discovery_controller_spec.rb
@@ -8,7 +8,7 @@ describe Api::OpenidConnect::DiscoveryController, type: :controller do
 
     it "should return a url to the openid-configuration" do
       json_body = JSON.parse(response.body)
-      expect(json_body["links"].first["href"]).to eq("http://test.host/api/openid_connect")
+      expect(json_body["links"].first["href"]).to eq("http://test.host/")
     end
 
     it "should return the resource in the subject" do
-- 
GitLab