Skip to content

Commit c1e83cd

Browse files
author
awb99
committed
webly 0.9 fixes
1 parent 8b57c01 commit c1e83cd

File tree

10 files changed

+35
-29
lines changed

10 files changed

+35
-29
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ karma.conf.js
3232
package.json
3333
package-lock.json
3434
shadow-cljs.edn
35-
goldly_bindings_generated.cljs
35+
.gorilla

demo/deps.edn

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
"target/webly"]
44

55
:deps {org.clojure/clojure {:mvn/version "1.11.3"}
6-
org.pinkgorilla/webly {:mvn/version "0.8.707"}
6+
org.pinkgorilla/webly {:mvn/version "0.9.716"}
77
org.pinkgorilla/ui-tailwind {:mvn/version "0.1.8"}
8-
org.pinkgorilla/websocket {:mvn/version "0.0.23"} ; more up to date than in webly
98
org.pinkgorilla/oauth2 {:local/root "../" :deps/manifest :deps}
109
nrepl/nrepl {:mvn/version "1.2.0"}}
1110

12-
:aliases {:npm-install {:exec-fn webly.app.app/webly-build
11+
:aliases {:npm-install {:exec-fn webly.spa/webly-build
1312
:exec-args {:config [{}]
1413
:profile "npm-install"}}
1514
:demo {:exec-fn modular.system/start!

demo/resources/demo-services.edn

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{:modular (modular.system/modular-env) ; {:profile "jetty" :config ["demo.edn" "secrets.edn"]}
22
;:secrets #include "secrets.edn" ;; externalised and usually "mounted" as a docker/kubernetes secret
33
:components
4-
{:config {:start (modular.config/load-config! (:config #ref [:modular]))}
4+
{:config1 {:start (modular.config/load-config! (:config #ref [:modular]))}
5+
:config {:start (deref (clip/ref :config1))}
56

67
:timbre {:start (modular.log/timbre-config!
7-
(:timbre/clj (deref (clip/ref :config))))}
8+
(:timbre/clj (clip/ref :config)))}
89

910
:exts {:start (extension/discover)}
1011

@@ -33,14 +34,14 @@
3334

3435
:oauth2 {:start (token.oauth2.service/start-oauth2-service
3536
{:clj (clip/ref :clj-service)
36-
:providers (:oauth2 (:token (deref (clip/ref :config))))
37-
:store-path ".webly/tokenstore"
37+
:providers (:oauth2 (:token (clip/ref :config)))
38+
:store-path ".gorilla/tokenstore"
3839
:store-role nil ; #{}
3940
})}
4041

41-
:webly {:start (webly.app.app/start-webly
42-
(clip/ref :exts)
43-
(deref (clip/ref :config))
42+
:webly {:start (webly.spa/start-webly
43+
{:exts (clip/ref :exts)}
44+
(clip/ref :config)
4445
(:profile #ref [:modular]))
4546
:stop (webly.app.app/stop-webly this)}
4647

deps.edn

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
reagent/reagent {:mvn/version "1.1.1"} ; https://github.com/reagent-project/reagent
99
com.cemerick/url {:mvn/version "0.1.1"} ; url query-strings
1010
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"} ; needed for re-frame/http-fx
11-
;simplevalue/letsencrypt {:git/url "https://github.com/SimpleValue/sv.letsencrypt.git"
12-
; :sha "8b1a85846acaaa37a58b054f2372d8fde0663b75"}
11+
babashka/fs {:mvn/version "0.5.22"} ; create dir
1312

1413
;; JWT / auth deps
1514
buddy/buddy-core {:mvn/version "1.10.1"}
@@ -24,7 +23,7 @@
2423
; clj-oauth/clj-oauth {:mvn/version "1.5.2"}; copied over from REST
2524
; pink-gorilla dependencies
2625
org.pinkgorilla/modular {:mvn/version "0.2.61"} ; for edn saving (with time formats encoding added)
27-
org.pinkgorilla/clj-service {:mvn/version "0.4.21"} ; brings permission + websocket
26+
org.pinkgorilla/clj-service {:mvn/version "0.4.22"} ; brings permission + websocket
2827
}
2928

3029
:aliases

resources/ext/oauth2.edn

+17-7
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,29 @@
1212
token.identity.ui {'user-icon-with-login token.identity.ui/user-icon-with-login
1313
'show-login-dialog token.identity.ui/show-login-dialog}}
1414
; run
15-
:api-routes {; oauth redirect is stateless,
15+
16+
:web/routes [; oauth redirect is stateless,
1617
; all other endpoints are implemented via clj-service which can be started at runtime
1718
; if the service gets started.
18-
"oauth2/" {;["start/" :provider] {:get modular.oauth2.handler/handler-oauth2-start-wrapped}
19+
["/api/oauth2/"
20+
["redirect/:provider" {;Path Param: :provider will be extracted and passed to user-handler under :path-params.
21+
:handler token.oauth2.handler.redirect/handler-oauth2-redirect ; either client OR server side
22+
:middleware [; this was ws-wrap
23+
;webserver.middleware.api/wrap-api-handler
24+
[ring.middleware.defaults/wrap-defaults ring.middleware.defaults/site-defaults]
25+
ring.middleware.keyword-params/wrap-keyword-params
26+
ring.middleware.params/wrap-params]
27+
}]
28+
;["start/" :provider] {:get modular.oauth2.handler/handler-oauth2-start-wrapped}
1929
;"token" {:get modular.oauth2.handler/token-handler-wrapped}
2030
; ["redirect/" :provider] {:get :oauth2/redirect}
2131
;"save-token" {:post modular.oauth2.handler/handler-oauth2-save-wrapped}
22-
["redirect/" :provider] token.oauth2.handler/handler-oauth2-redirect-wrapped ; either client OR server side
23-
}}
32+
]]
2433

25-
:cljs-service {;:config-fn webly.spa.service/cljs-config-simple
26-
:start-fn token.identity.user/init-user!
27-
:default-config {}}
34+
35+
:cljs-service {;:config-fn webly.spa.service/cljs-config-simple
36+
:start-fn token.identity.user/init-user!
37+
:default-config {}}
2838

2939

3040
}

TODO.md src-unused/TODO.md

File renamed without changes.

src-unused/config.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
; creds (set them in creds.edn resource)
3-
:oauth2 {:token-path ".webly/tokenstore/"
3+
:oauth2 {:token-path ".gorilla/tokenstore/"
44
:github {;https://docs.github.com/en/rest/reference/permissions-required-for-github-apps
55
:token-prefix "token "}
66
:google {:token-prefix "Bearer "}
File renamed without changes.

src/token/oauth2/handler/redirect.clj

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
qp (:query-params req)]
2222
(debug "oauth2/authorize-response: params:" p)
2323
(debug "oauth2/authorize-response: query-params:" qp)
24-
(let [provider (get-in req [:route-params :provider])
24+
(let [;provider (get-in req [:route-params :provider]) ; bidi style
25+
provider (get-in req [:path-params :provider]) ; reitit style
2526
res (response/content-type {:status 200
2627
:body (page-oauth2-redirect provider)}
2728
"text/html")]

src/token/oauth2/store.clj

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
(ns token.oauth2.store
22
(:require
33
[taoensso.timbre :as timbre :refer [info]]
4-
[clojure.java.io :as io]
4+
[babashka.fs :as fs]
55
[clj-service.core :refer [expose-functions]]
66
[modular.persist.protocol :refer [save loadr]]
77
[modular.persist.edn] ; side effects to be able to save edn files
88
[token.oauth2.token :refer [sanitize-token]]))
99

10-
(defn- ensure-directory [path]
11-
(when-not (.exists (io/file path))
12-
(.mkdir (java.io.File. path))))
13-
1410
(defn create-store [{:keys [store-path clj store-role] :as this}]
1511
;(println "token store: " path)
16-
(ensure-directory store-path)
12+
(fs/create-dirs store-path)
1713
(when clj
1814
(info "exposing oauth2-store service permission: " store-role " .. ")
1915
(expose-functions clj

0 commit comments

Comments
 (0)