Skip to content

Commit

Permalink
Add url-prefix restrictions to config spec
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinqian00 committed Dec 17, 2024
1 parent 25c871b commit 52a0c7e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/lrsql/spec/config.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns lrsql.spec.config
(:require [clojure.spec.alpha :as s]
[clojure.string :as cstr]
[xapi-schema.spec :as xs]
[lrsql.spec.util :as u]))

Expand Down Expand Up @@ -107,6 +108,14 @@
[{:keys [pool-validation-timeout pool-connection-timeout]}]
(< pool-validation-timeout pool-connection-timeout))))

(defn- prefix? [s]
(cstr/starts-with? s "/"))

(defn- not-admin-prefix? [s]
(not (cstr/starts-with? s "/admin")))

(s/def ::stmt-url-prefix (s/and string? prefix? not-admin-prefix?))

(s/def ::admin-user-default string?)
(s/def ::admin-pass-default string?)

Expand Down Expand Up @@ -147,6 +156,7 @@
(s/def ::http-host string?)
(s/def ::http-port nat-int?)
(s/def ::ssl-port nat-int?)
(s/def ::url-prefix ::stmt-url-prefix)

(s/def ::allow-all-origins boolean?)
(s/def ::allowed-origins (s/nilable (s/coll-of string?)))
Expand Down

0 comments on commit 52a0c7e

Please # to comment.