Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL-264] JWT Renewal + re-route implementation #99

Open
wants to merge 100 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
92a7bf0
Use logout endpoint in logout handler
kelvinqian00 Nov 5, 2024
3bdbed0
Add session clear-token and clear-username handlers
kelvinqian00 Nov 5, 2024
7deaf77
Use reg-global-interceptor instead of manually adding
kelvinqian00 Nov 9, 2024
257a5fe
Add new-account to db
kelvinqian00 Nov 9, 2024
ac32bf2
Instrument all effects with interaction interceptor
kelvinqian00 Nov 9, 2024
5348535
Add last-interaction-time to db
kelvinqian00 Nov 9, 2024
f6967de
Add docstring to interaction-interceptor
kelvinqian00 Nov 9, 2024
abbb760
Add timeout and renewal effects
kelvinqian00 Nov 9, 2024
80a3b60
Replace jwt-exp-time with jwt-refresh-interval and jwt-interaction-wi…
kelvinqian00 Nov 11, 2024
48688e3
Dispatch renewal event on login, not init
kelvinqian00 Nov 11, 2024
180f026
Don't renew JWT if logged out
kelvinqian00 Nov 11, 2024
1489756
Remove printlns
kelvinqian00 Nov 11, 2024
472640c
Log out upon renewal failure
kelvinqian00 Nov 11, 2024
51bff1f
Call admin/verify before loading xapi in stmt browser
kelvinqian00 Nov 11, 2024
0b0f7cb
Add verify-login handler to check login upon refresh
kelvinqian00 Nov 11, 2024
0c8bfbb
Update comments
kelvinqian00 Nov 11, 2024
013c0e4
Remove anomalous comment
kelvinqian00 Nov 11, 2024
793e3f3
Use clear-token event in server error
kelvinqian00 Nov 11, 2024
fb62591
Extract out placeholder token
kelvinqian00 Nov 11, 2024
a95f482
No calls to verify endpoint in OIDC auth
kelvinqian00 Nov 11, 2024
93fe314
Resection and rename login/logout handlers
kelvinqian00 Nov 12, 2024
406d577
Update server-error for 401s and use it more
kelvinqian00 Nov 12, 2024
ea2b725
Add re-route dep
kelvinqian00 Nov 12, 2024
48033fe
Create not-found view
kelvinqian00 Nov 12, 2024
69451f5
Add routes namespace
kelvinqian00 Nov 12, 2024
b3acced
Init routes in handler
kelvinqian00 Nov 12, 2024
d27e5c5
Fix route controllers
kelvinqian00 Nov 12, 2024
db56bb1
Move router init to core ns
kelvinqian00 Nov 12, 2024
5f6773c
Add home page
kelvinqian00 Nov 12, 2024
e778b5f
Use route-view sub in main view
kelvinqian00 Nov 12, 2024
5e57370
Replace session/set-page and get-page with re-route
kelvinqian00 Nov 12, 2024
8c94b90
Delete dispatches from views themselves
kelvinqian00 Nov 12, 2024
e09c109
Add status/get-all-data effect
kelvinqian00 Nov 12, 2024
3e5ba52
Remove session page and associated fx + subs
kelvinqian00 Nov 12, 2024
eddb148
Change /password to /accounts/password
kelvinqian00 Nov 12, 2024
869016a
Clean up 404 Not Found page with lang/get
kelvinqian00 Nov 12, 2024
b9bd613
Add /ui prefix in front of all routes
kelvinqian00 Nov 15, 2024
792ad96
Should actually be /admin/ui
kelvinqian00 Nov 15, 2024
0131d19
Remove routes for disabled pages
kelvinqian00 Nov 15, 2024
a582a9f
Add ring router to support different URL paths
kelvinqian00 Nov 12, 2024
5c2f29e
Move dev directory to top level
kelvinqian00 Nov 13, 2024
65cb96e
Make resource paths absolute, not relative
kelvinqian00 Nov 13, 2024
db0a943
Make all image src paths absolute
kelvinqian00 Nov 13, 2024
f86d392
Make paths relative in prod mode
kelvinqian00 Nov 13, 2024
a0f4516
Figwheel now opens on /admin/ui
kelvinqian00 Nov 15, 2024
e8f35a8
Update handler to imitate backend redirects
kelvinqian00 Nov 15, 2024
9cf0c9c
Revert "Make paths relative in prod mode"
kelvinqian00 Nov 18, 2024
4e565ad
Change how prod admin/env path is constructed
kelvinqian00 Nov 19, 2024
f39183e
Update package-lock.json
kelvinqian00 Nov 19, 2024
ba6f224
Prefix prod paths with /admin
kelvinqian00 Nov 20, 2024
83b376e
Use subs to change src paths depending on dev vs prod
kelvinqian00 Nov 20, 2024
c11c3f9
Merge branch 're-route-path-updates' into re-route-impl-2
kelvinqian00 Nov 20, 2024
bbe7ecb
Remove unused require
kelvinqian00 Nov 20, 2024
4927337
Merge branch 're-route-path-updates' into re-route-impl-2
kelvinqian00 Nov 20, 2024
5003e14
Add TODO for future reactions routes
kelvinqian00 Nov 20, 2024
d92c153
Add prefix to index_prod.html to make it a Selmer template
kelvinqian00 Nov 21, 2024
2faf9da
Append image src paths with proxy prefix
kelvinqian00 Nov 21, 2024
dcfb335
Append routes with proxy prefix
kelvinqian00 Nov 21, 2024
14db3b7
Add prefix to index_prod.html to make it a Selmer template
kelvinqian00 Nov 21, 2024
f9f9ae9
Append image src paths with proxy prefix
kelvinqian00 Nov 21, 2024
9cccf87
Merge branch 're-route-path-updates' into re-route-impl-2
kelvinqian00 Nov 21, 2024
e0baec1
Merge branch 'main' into jwt-enhancements-2
kelvinqian00 Nov 22, 2024
2935e87
Merge branch 'main' into re-route-path-updates
kelvinqian00 Nov 22, 2024
9480840
Merge branch 're-route-path-updates' into re-route-impl-2
kelvinqian00 Nov 22, 2024
ab7efaa
Remove now-unused require
kelvinqian00 Nov 22, 2024
773c1d1
Merge branch 're-route-path-updates' into re-route-impl-2
kelvinqian00 Nov 22, 2024
35cc206
Replace reaction-view with mode-specific components
kelvinqian00 Nov 25, 2024
ae5efed
Separate action button bars
kelvinqian00 Nov 25, 2024
82533df
Add sections
kelvinqian00 Nov 25, 2024
af11eae
Refactor ruleset-view
kelvinqian00 Nov 25, 2024
28770e6
Refactor render-conditions
kelvinqian00 Nov 25, 2024
ba405d2
Refactor render-or-edit-condition-name
kelvinqian00 Nov 25, 2024
4210958
Refactor render-clause
kelvinqian00 Nov 25, 2024
caa8b7c
Refactor path, op, val, and ref components
kelvinqian00 Nov 25, 2024
9c2a498
Refactor render-identity-paths
kelvinqian00 Nov 25, 2024
9969f5d
Refactor render-view-or-edit-template
kelvinqian00 Nov 25, 2024
57d26ea
Rename some components
kelvinqian00 Nov 25, 2024
fb87a7e
Refactor out reaction-ruleset-view
kelvinqian00 Nov 25, 2024
36a7215
Remove redundant ruleset-new components
kelvinqian00 Nov 25, 2024
7b3e827
Rename rest of render- components
kelvinqian00 Nov 25, 2024
e02bfca
Even more sectioning
kelvinqian00 Nov 25, 2024
b950816
Properly avoid calling local-display on nils
kelvinqian00 Nov 26, 2024
dc61539
Add new reactions routes + views
kelvinqian00 Nov 26, 2024
db68367
Use new reaction routes
kelvinqian00 Nov 26, 2024
2ac715c
Slight reformatting of route map
kelvinqian00 Nov 26, 2024
df262dd
Refactor cancel-edit into clear-edit
kelvinqian00 Nov 26, 2024
037ec2a
Only dispatch unset-focus when leaving the focus page
kelvinqian00 Nov 26, 2024
2dd5ff5
Delete back-to-list effect
kelvinqian00 Nov 26, 2024
3ad18d0
Delete reaction mode sub
kelvinqian00 Nov 26, 2024
c327279
Add edit-error? sub
kelvinqian00 Nov 26, 2024
626f5c4
Add some TODOs for edit saving
kelvinqian00 Nov 26, 2024
311d3f7
Merge pull request #91 from yetanalytics/jwt-enhancements-2
kelvinqian00 Jan 14, 2025
10dd806
Merge pull request #93 from yetanalytics/re-route-path-updates
kelvinqian00 Jan 14, 2025
79a43c1
Merge branch 'admin-jwt-renew-reroute-epic' into re-route-impl-2
kelvinqian00 Jan 14, 2025
37aaa8e
Remove stray println
kelvinqian00 Jan 14, 2025
f1eeaec
Fix compiler warnings caused by merge commit
kelvinqian00 Jan 14, 2025
f1f4a44
Slightly refactor routes in set-env
kelvinqian00 Jan 14, 2025
606edee
Merge pull request #94 from yetanalytics/re-route-impl-2
kelvinqian00 Jan 14, 2025
eff8d2b
Merge branch 'admin-jwt-renew-reroute-epic' into re-route-impl-reactions
kelvinqian00 Jan 14, 2025
c1755c1
Merge pull request #96 from yetanalytics/re-route-impl-reactions
kelvinqian00 Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[cljsjs/oidc-client
reagent/reagent
re-frame/re-frame]}
com.yetanalytics/re-route {:mvn/version "0.1.0"}
com.yetanalytics/xapi-schema {:mvn/version "1.2.3"}
com.fasterxml.jackson.core/jackson-core {:mvn/version "2.11.4"}
com.fasterxml.jackson.dataformat/jackson-dataformat-smile
Expand All @@ -37,6 +38,8 @@
:build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]}
:min {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]}
:test {:main-opts ["-m" "figwheel.main" "-co" "test.cljs.edn" "-m" "com.yetanalytics.lrs-admin-ui.test-runner"]}
:dev {:extra-deps
:dev {:extra-paths
["dev"]
:extra-deps
{day8.re-frame/tracing {:mvn/version "0.6.2"}
day8.re-frame/re-frame-10x {:mvn/version "1.2.2"}}}}}
4 changes: 3 additions & 1 deletion dev.cljs.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
^{:watch-dirs ["src" "test"]
:css-dirs ["resources/public/css"]
:auto-testing true
:auto-bundle :webpack}
:auto-bundle :webpack
:ring-handler com.yetanalytics.lrs-admin-ui.server/handler
:open-url "http://[[server-hostname]]:[[server-port]]/admin/ui"}
{:main com.yetanalytics.lrs-admin-ui.core
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:preloads [day8.re-frame-10x.preload]}
18 changes: 18 additions & 0 deletions dev/com/yetanalytics/lrs_admin_ui/server.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(ns com.yetanalytics.lrs-admin-ui.server
"Ring handler only for dev/figwheel to serve multiple paths"
(:require [ring.util.request :as req]
[ring.util.response :as resp]))

(defn handler [request]
(cond
(not= :get (:request-method request))
{:status 405
:headers {"Context-Type" "text/plain"}
:body "Unsupported Operation!"}
;; Imitate backend redirects
;; NOTE: "/" will actually not get redirected since Figwheel handles
;; that separately.
(#{"/" "/admin" "/admin/"} (req/path-info request))
(resp/redirect "/admin/ui")
:else
(resp/file-response "resources/public/")))
14 changes: 7 additions & 7 deletions resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" sizes="180x180" href="images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
<link rel="manifest" href="images/favicon/site.webmanifest">
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon/favicon-16x16.png">
<link rel="manifest" href="/images/favicon/site.webmanifest">
<title>Yet Analytics LRS</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="css/custom.css" rel="stylesheet" type="text/css">
<link href="/css/style.css" rel="stylesheet" type="text/css">
<link href="/css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="app">
</div>
<script src="cljs-out/dev/main_bundle.js" type="text/javascript"></script>
<script src="/cljs-out/dev/main_bundle.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
com.yetanalytics.lrs_admin_ui.core.init("http://localhost:8080");
Expand Down
14 changes: 7 additions & 7 deletions resources/public/index_prod.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" sizes="180x180" href="images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
<link rel="manifest" href="images/favicon/site.webmanifest">
<link rel="apple-touch-icon" sizes="180x180" href="{{prefix}}/admin/images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="{{prefix}}/admin/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="{{prefix}}/admin/images/favicon/favicon-16x16.png">
<link rel="manifest" href="{{prefix}}/admin/images/favicon/site.webmanifest">
<title>Yet Analytics LRS</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="css/custom.css" rel="stylesheet" type="text/css">
<link href="{{prefix}}/admin/css/style.css" rel="stylesheet" type="text/css">
<link href="{{prefix}}/admin/css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="app">
</div>
<script src="main.js" type="text/javascript"></script>
<script src="{{prefix}}/admin/main.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
com.yetanalytics.lrs_admin_ui.core.init();
Expand Down
2 changes: 1 addition & 1 deletion src/com/yetanalytics/lrs_admin_ui/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
(:require
[goog.dom :as gdom]
[reagent.dom :as rdom]
[re-frame.core :refer [dispatch-sync]]
[com.yetanalytics.lrs-admin-ui.subs]
[com.yetanalytics.lrs-admin-ui.handlers]
[re-frame.core :refer [dispatch-sync]]
[com.yetanalytics.lrs-admin-ui.views :as views]))

(set! *warn-on-infer* true)
Expand Down
16 changes: 12 additions & 4 deletions src/com/yetanalytics/lrs_admin_ui/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
;; Spec to define the db
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(s/def :session/page keyword?)
(s/def :session/token (s/nilable string?))
(s/def :session/username (s/nilable string?))
(s/def ::session
(s/keys :req-un [:session/page
:session/token
(s/keys :req-un [:session/token
:session/username]))

(s/def :login/username (s/nilable string?))
Expand Down Expand Up @@ -82,6 +80,7 @@
(s/def ::server-host string?)
(s/def ::xapi-prefix string?) ;; default /xapi
(s/def ::proxy-path (s/nilable string?)) ;; default nil
(s/def ::resource-base string?)

(s/def ::pref-lang keyword?)
(s/def ::language map?)
Expand Down Expand Up @@ -186,12 +185,18 @@

(s/def ::no-val-logout-url string?)

(s/def ::jwt-refresh-interval int?)
(s/def ::jwt-interaction-window int?)
(s/def ::last-interaction-time int?)

(s/def ::db (s/keys :req [::session
::credentials
::login
::browser
::accounts
::new-account
::server-host
::resource-base
::xapi-prefix
::proxy-path
::language
Expand All @@ -205,7 +210,10 @@
::status
::update-password
::enable-reactions
::reactions]
::reactions
::jwt-refresh-interval
::jwt-interaction-window
::last-interaction-time]
:opt [::reaction-focus
::editing-reaction
::editing-reaction-template-errors
Expand Down
17 changes: 13 additions & 4 deletions src/com/yetanalytics/lrs_admin_ui/functions/http.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,19 @@


;;JWTs
(defn add-jwt [{:keys [headers] :as request}]
(assoc request :headers
(conj headers {"Authorization"
(format "Bearer %s" @(subscribe [:session/get-token]))})))

(defn add-jwt* [token {:keys [headers] :as request}]
(assoc request
:headers
(conj headers {"Authorization" (format "Bearer %s" token)})))

(defn add-jwt [request]
(let [token @(subscribe [:session/get-token])]
(add-jwt* token request)))

(defn add-jwt-interceptor* [token]
(to-interceptor {:name "JWT Authentication Interceptor"
:request (partial add-jwt* token)}))

(def add-jwt-interceptor
(to-interceptor {:name "JWT Authentication Interceptor"
Expand Down
Loading
Loading