This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-14
Channels
- # 100-days-of-code (4)
- # announcements (1)
- # beginners (63)
- # boot (22)
- # braveandtrue (104)
- # calva (3)
- # cider (12)
- # cljs-dev (53)
- # cljsjs (3)
- # cljsrn (1)
- # clojure (180)
- # clojure-dev (14)
- # clojure-italy (4)
- # clojure-nl (11)
- # clojure-spec (15)
- # clojure-uk (60)
- # clojure-ukraine (1)
- # clojurescript (118)
- # clojutre (3)
- # core-async (12)
- # core-logic (17)
- # cursive (19)
- # datomic (45)
- # devcards (4)
- # emacs (7)
- # figwheel-main (218)
- # fulcro (27)
- # funcool (3)
- # graphql (1)
- # jobs (4)
- # leiningen (57)
- # off-topic (71)
- # pedestal (2)
- # portkey (17)
- # re-frame (5)
- # reitit (4)
- # remote-jobs (2)
- # ring (11)
- # rum (2)
- # shadow-cljs (14)
- # specter (11)
- # sql (34)
- # tools-deps (23)
Hi I am trying to use buddy to validate tokens from Amazon cognito, but they use JWK, has anyone else attempted this before?
It basically means you have to get a public key from an endpoint and then use that to unsign the JWT token but I am not quite sure how, I found this to get the public key:
(:import java.math.BigInteger
java.security.KeyFactory
java.security.PublicKey
java.security.spec.RSAPublicKeySpec
org.bouncycastle.jcajce.provider.asymmetric.rsa.BCRSAPublicKey)
(defn jwk->public-key [jwk]
(let [kty (get jwk :kty)
n (some-> (get jwk :n)
^bytes (base64/decode)
(BigInteger.))
e (some-> (get jwk :e)
^bytes (base64/decode)
(BigInteger.))]
(and kty n e
(->> (RSAPublicKeySpec. n e)
(.generatePublic (KeyFactory/getInstance kty))))))
Oh it seems there is some support but I need to upgrade buddy.. Sorry for the noise