Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here my bare testing program.
- (ns ringauth2.core
- (:require [ring.adapter.jetty :refer [run-jetty]]
- [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
- [ring.middleware.params :refer [wrap-params]]
- [ringauth2.oauth2 :refer [wrap-oauth2]]))
- (defn handler [request]
- {:status 200
- :headers {"Content-Type" "text/html"}
- :body "Hello World"})
- (def authmap
- {:google
- {:authorize-uri "https://accounts.google.com/o/oauth2/v2/auth"
- :access-token-uri "https://www.googleapis.com/oauth2/v4/token"
- :client-id "xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"
- :client-secret "xxxxxxxxxxxxx"
- :scopes ["openid" "email"]
- :launch-uri "/oauth2/google"
- :redirect-uri "/oauth2/google/callback"
- :landing-uri "/xxxxxxx/"}})
- (run-jetty
- (-> handler
- (wrap-defaults (-> site-defaults
- (assoc-in [:session :cookie-attrs :same-site] :lax)))
- wrap-params
- (wrap-oauth2 authmap))
- {:port 3000})
- ----------------------------------------------------------------------------
- Following are my tests for wrap-params. It works when I delete the map entry consisting of :body and http object.
- (def hui (wrap-params identity))
- =>#'ringauth2.core/hui
- (hui {:http-method :get
- :uri "/search"
- :query-string "q=clojure"})
- =>{:http-method :get, :uri "/search", :query-string "q=clojure", :form-params {}, :params {"q" "clojure"}, :query-params {"q" "clojure"}}
- (hui {:ssl-client-cert nil,
- :protocol "HTTP/1.1",
- :remote-addr "0:0:0:0:0:0:0:1",
- :headers
- {"cookie"
- "_ga=GA1.1.1568628036.1504630106; JSESSIONID=XblSvyd4TRQBGr76HYELgJ6cpH6D43oP8OBLAhZc; ring-session=334f1f4e-9268-468c-add1-1c8633e36b5f",
- "accept"
- "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
- "upgrade-insecure-requests" "1",
- "user-agent"
- "Mozilla/5.0 (X11; FreeBSD amd64; rv:57.0) Gecko/20100101 Firefox/57.0",
- "connection" "keep-alive",
- "host" "localhost:3000",
- "accept-language" "en-US,en;q=0.5",
- "accept-encoding" "gzip, deflate",
- "dnt" "1"},
- :server-port 3000,
- :content-length nil,
- :content-type nil,
- :character-encoding nil,
- :uri "/oauth2/google/callback",
- :server-name "localhost",
- :query-string
- "state=58icXHjzuI6N&code=4/Ku-s-yzLPns_VFCfwCh5vnAqzBpNRAbmVt8G9dAbwKo&authuser=1&hd=isgpm.de&session_state=aee5df07c30a9e6d663efa84435749938698a62d..a435&prompt=consent",
- :body
- #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x30f90d3 "HttpInputOverHTTP@30f90d3"]
- ,
- :scheme :http,
- :request-method :get})
- =>java.lang.RuntimeException Unmatched delimiter: )
- (hui {:protocol "HTTP/1.1",
- :remote-addr "0:0:0:0:0:0:0:1",
- :headers
- {"cookie"
- "_ga=GA1.1.1568628036.1504630106; JSESSIONID=XblSvyd4TRQBGr76HYELgJ6cpH6D43oP8OBLAhZc; ring-session=334f1f4e-9268-468c-add1-1c8633e36b5f",
- "accept"
- "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
- "upgrade-insecure-requests" "1",
- "user-agent"
- "Mozilla/5.0 (X11; FreeBSD amd64; rv:57.0) Gecko/20100101 Firefox/57.0",
- "connection" "keep-alive",
- "host" "localhost:3000",
- "accept-language" "en-US,en;q=0.5",
- "accept-encoding" "gzip, deflate",
- "dnt" "1"},
- :server-port 3000,
- :content-length nil,
- :content-type nil,
- :character-encoding nil,
- :uri "/oauth2/google/callback",
- :server-name "localhost",
- :query-string
- "state=58icXHjzuI6N&code=4/Ku-s-yzLPns_VFCfwCh5vnAqzBpNRAbmVt8G9dAbwKo&authuser=1&hd=isgpm.de&session_state=aee5df07c30a9e6d663efa84435749938698a62d..a435&prompt=consent"})
- =>{:protocol "HTTP/1.1", :remote-addr "0:0:0:0:0:0:0:1", :params {"state" "58icXHjzuI6N", "code" "4/Ku-s-yzLPns_VFCfwCh5vnAqzBpNRAbmVt8G9dAbwKo", "authuser" "1", "hd" "isgpm.de", "session_state" "aee5df07c30a9e6d663efa84435749938698a62d..a435", "prompt" "consent"}, :headers {"host" "localhost:3000", "user-agent" "Mozilla/5.0 (X11; FreeBSD amd64; rv:57.0) Gecko/20100101 Firefox/57.0", "cookie" "_ga=GA1.1.1568628036.1504630106; JSESSIONID=XblSvyd4TRQBGr76HYELgJ6cpH6D43oP8OBLAhZc; ring-session=334f1f4e-9268-468c-add1-1c8633e36b5f", "connection" "keep-alive", "upgrade-insecure-requests" "1", "accept" "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "accept-language" "en-US,en;q=0.5", "accept-encoding" "gzip, deflate", "dnt" "1"}, :server-port 3000, :content-length nil, :form-params {}, :query-params {"state" "58icXHjzuI6N", "code" "4/Ku-s-yzLPns_VFCfwCh5vnAqzBpNRAbmVt8G9dAbwKo", "authuser" "1", "hd" "isgpm.de", "session_state" "aee5df07c30a9e6d663efa84435749938698a62d..a435", "prompt" "consent"}, :content-type nil, :character-encoding nil, :uri "/oauth2/google/callback", :server-name "localhost", :query-string "state=58icXHjzuI6N&code=4/Ku-s-yzLPns_VFCfwCh5vnAqzBpNRAbmVt8G9dAbwKo&authuser=1&hd=isgpm.de&session_state=aee5df07c30a9e6d663efa84435749938698a62d..a435&prompt=consent"}
Add Comment
Please, Sign In to add comment