(ns superapi.ions.auth
[:require [clojure.data.json :as json]
[datomic.ion :as ion]
[buddy.sign.jwt :as jwt]])
(defn gateway-authorizer
"Validate that a user's JWT signature and expiration date"
[{:keys [input] :as ion}]
(let [
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app.deploy | |
(:require | |
[datomic.ion.dev :as dev] | |
[taoensso.timbre :refer [infof]])) | |
(defn check-status-loop [{arn :execution-arn :as args}] | |
(let [{:keys [deploy-status code-deploy-status] :as status} | |
(dev/deploy-status {:op :deploy-status | |
:execution-arn arn})] | |
(if (contains? (set [deploy-status code-deploy-status]) "RUNNING") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns signit | |
(:require [buddy.core.dsa :as dsa] | |
[buddy.core.codecs.base64 :as b64] | |
[clojure.string :as str]) | |
(:import [java.security Signature])) | |
(defn access-policy | |
"Create a stringified JSON policy to grant access to a URL until a given Epoch time" | |
[url exp] | |
(str "{\"Statement\":[{\"Resource\":\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defonce secret-number (atom 0)) | |
(defn reset-game | |
"Reset the secret-number atom to an integer between 0 and the highest-number" | |
[highest-number] | |
(when (reset! secret-number (rand-int (inc highest-number))) | |
(println (str "I am thinking of a number between 0 and " highest-number )))) | |
(defn guess | |
"Make a guess at the secret number." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn some-generic-function | |
"Demonstrate Clojure indentation and styles. | |
This doc string spans multiple lines, and the beginning of each line | |
is inline with the opening quotation mark" | |
[] | |
; ns :require values are aligned | |
; ns :import values are aligned | |
; but :require values do not align with :import values | |
(ns project.namespace |
(defn get-proxy-uri
"Parse the proxied uri forwarded by the ions api-gateway data"
[req]
(try
(let [path (-> req :datomic.ion.edn.api-gateway/json (json/read-str :key-fn keyword) :pathParameters :proxy)]
(str "/" path))
(catch Exception e nil)))
(defn wrap-proxy-uri
# Hitting the proxy resource endpoint /datomic returns the query results from the Ionized handler
curl https://$(obfuscated-name).execute-api.us-east-1.amazonaws.com/dev/datomic -d :hat
#{["SKU-19" 28499341391953988 23934169113428033 false]
...
["SKU-55" 46139905947992133 32330039903125571 false]}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```bash | |
# Hitting the proxy resource endpoint returns the query results from the Ionized handler | |
curl https://$(obfuscated-name).execute-api.us-east-1.amazonaws.com/dev/datomic -d :hat | |
#{["SKU-19" 28499341391953988 23934169113428033 false] | |
... | |
["SKU-55" 46139905947992133 32330039903125571 false]} | |
# Hitting a sub-resource returns the same thinng |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> #'testapp.core/client | |
(def conn (d/connect client {:db-name "my-db"})) | |
CompilerException clojure.lang.ExceptionInfo: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter #:cognitect.anomalies{:category :cognitect.anomalies/fault, :message "java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter"}, compiling:(form-init692047429040487558.clj:1:11) | |
(pst) | |
CompilerException clojure.lang.ExceptionInfo: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter #:cognitect.anomalies{:category :cognitect.anomalies/fault, :message "java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter"}, compiling:(form-init692047429040487558.clj:1:11) | |
clojure.lang.Compiler$InvokeExpr.eval (Compiler.java:3700) | |
clojure.lang.Compiler$DefExpr.eval (Compiler.java:457) | |
clojure.lang.Compiler.eval (Compiler.java:7067) | |
clojure.lang.Compiler.eval (Compiler.java:7025) | |
clojure.core/eval (core.clj:3206) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; [com.datomic/client-cloud "0.8.56"] | |
(require '[datomic.client.api :as d]) | |
; => nil | |
(def client (d/client {:server-type :cloud | |
:region "..." | |
:system "..." | |
:query-group "..." | |
:endpoint "http://....datomic.net:8182/" |
NewerOlder