1

私は Clojure を初めて使用し、Luminus を使用して Web サイトを構築しています。OpenID を自分のサイトに統合しようとしていますが、ひどく失敗しています。私はこのコード例を持っています:

https://github.com/cemerick/friend-demo/blob/master/src/clj/cemerick/friend_demo/openid.clj

デモ: http://friend-demo.herokuapp.com/openid/

私はそれを自分のサイトに実装しようとしていますが、エラーが発生し続けています. だから私は私のhome.cljにこのコードを持っています

ログインボタンをクリックするたびに、localhost:3000/login で「Not Found」が表示されます。

/login を多少処理する必要があるということですか? ただし、上記のコード例には記載されていません。

(def providers [{:name "Steam" :url "http://steamcommunity.com/openid"}
{:name "Yahoo" :url "http://me.yahoo.com/"}])

(defroutes home-routes
(GET "/" req
(h/html5
  pretty-head
  (pretty-body
   ; (github-link req)
   [:h2 "Authenticating with various services using OpenID"]
   [:h3 "Current Status " [:small "(this will change when you log in/out)"]]
   (if-let [auth (friend/current-authentication req)]
    [:p "Some information delivered by your OpenID provider:"
    [:ul (for [[k v] auth
      :let [[k v] (if (= :identity k)
        ["Your OpenID identity" (str (subs v 0 (* (count v) 2/3)) "…")]
        [k v])]]
      [:li [:strong (str (name k) ": ")] v])]]
    [:div
    [:h3 "Login with…"]
    (for [{:keys [name url]} providers
     :let [base-login-url (context-uri req (str "/login?identifier=" url))
     dom-id (str (gensym))]]
     [:form {:method "POST" :action (context-uri req "login")
     :onsubmit (when (.contains ^String url "username")
       (format "var input = document.getElementById(%s); input.value = input.value.replace('username', prompt('What is your %s username?')); return true;"
         (str \' dom-id \') name))}
     [:input {:type "hidden" :name "identifier" :value url :id dom-id}]
     [:input {:type "submit" :class "button" :value name}]])
    [:p "…or, with a user-provided OpenID URL:"]
    [:form {:method "POST" :action (context-uri req "login")}
    [:input {:type "text" :name "identifier" :style "width:250px;"}]
    [:input {:type "submit" :class "button" :value "Login"}]]])
   [:h3 "Logging out"]
   [:p [:a {:href (context-uri req "logout")} "Click here to log out"] "."])))
(GET "/logout" req 
(friend/logout* (resp/redirect (str (:context req) "/")))))

(def page (friend/authenticate
home-routes
{:allow-anon? true
:default-landing-uri "/"
:workflows [(openid/workflow
:openid-uri "/login"
:credential-fn identity)]}))
4

1 に答える 1

0

/loginコールバックはによって処理され、openid-workflow本質的にあなたのhome-routes. home-routes代わりに使用する必要があるときに、リクエスト ハンドラーとして使用している可能性がありますpage

于 2015-07-27T11:06:24.263 に答える