Skip to content

Commit

Permalink
Merge pull request #13 from chetbox/master
Browse files Browse the repository at this point in the history
Fix wrap-oauth2
  • Loading branch information
DerGuteMoritz committed Dec 12, 2016
2 parents 9adcd00 + 1349876 commit b7fa427
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion project.clj
@@ -1,7 +1,7 @@
(def dev-dependencies (def dev-dependencies
'[[ring "0.3.11"]]) '[[ring "0.3.11"]])


(defproject clj-oauth2 "0.3.0" (defproject clj-oauth2 "0.3.1"
:description "clj-http and ring middlewares for OAuth 2.0" :description "clj-http and ring middlewares for OAuth 2.0"
:dependencies [[org.clojure/clojure "1.3.0"] :dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/data.json "0.1.1"] [org.clojure/data.json "0.1.1"]
Expand Down
15 changes: 8 additions & 7 deletions src/clj_oauth2/ring.clj
Expand Up @@ -115,10 +115,11 @@ create a vector of values."
"Returns true if this is a request to the callback URL" "Returns true if this is a request to the callback URL"
(let [oauth2-url-vector (string/split (.toString (java.net.URI. (:redirect-uri oauth2-params))) #"\?") (let [oauth2-url-vector (string/split (.toString (java.net.URI. (:redirect-uri oauth2-params))) #"\?")
oauth2-uri (nth oauth2-url-vector 0) oauth2-uri (nth oauth2-url-vector 0)
oauth2-url-params (nth oauth2-url-vector 1) oauth2-url-params (or (get oauth2-url-vector 1) "")
encoding (or (:character-encoding request) "UTF-8")] encoding (or (:character-encoding request) "UTF-8")]
(and (= oauth2-uri (request-uri request oauth2-params)) (and (= oauth2-uri (request-uri request oauth2-params))
(submap? (keyify-params (parse-params oauth2-url-params encoding)) (:params request))))) (submap? (keyify-params (parse-params oauth2-url-params encoding))
(keyify-params (:params request))))))


;; This Ring wrapper acts as a filter, ensuring that the user has an OAuth ;; This Ring wrapper acts as a filter, ensuring that the user has an OAuth
;; token for all but a set of explicitly excluded URLs. The response from ;; token for all but a set of explicitly excluded URLs. The response from
Expand All @@ -136,11 +137,11 @@ create a vector of values."
;; it in the response and redirect to the originally requested URL ;; it in the response and redirect to the originally requested URL
(let [response {:status 302 (let [response {:status 302
:headers {"Location" ((:get-target oauth2-params) request)}} :headers {"Location" ((:get-target oauth2-params) request)}}
oauth2-data (oauth2/get-access-token oauth2-data (oauth2/get-access-token
oauth2-params oauth2-params
(:params request) (keyify-params (:params request))
(oauth2/make-auth-request (oauth2/make-auth-request
oauth2-params oauth2-params
((:get-state oauth2-params) request)))] ((:get-state oauth2-params) request)))]
((:put-oauth2-data oauth2-params) request response oauth2-data)) ((:put-oauth2-data oauth2-params) request response oauth2-data))
;; We're not handling the callback ;; We're not handling the callback
Expand Down

0 comments on commit b7fa427

Please sign in to comment.