Release 0.3.0 with swapped arg order for unsign

Signed-off-by: Snorre Magnus Davøen's avatarSnorre Magnus Davøen <snorre.davoen@nsd.no>
parent 87d3b78a
Pipeline #14944 passed with stage
in 30 seconds
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## 0.3.0 - 2018-09-20
### Changed
- Swapped argument order for unsign function to make partial application easier
## 0.2.1 - 2018-09-20
### Added
- Error logging for failing key resolve
## 0.2.0 - 2018-09-19
### Added
- Added specs for unsign and generator for ::jwt
......
......@@ -5,7 +5,7 @@
A Clojure library to handle validation of JWTs.
```clojure
[no.nsd/clj-jwt "0.2.1"]
[no.nsd/clj-jwt "0.3.0"]
```
The library exposes functions to handle validation of JSON web tokens. It wraps
......
(defproject no.nsd/clj-jwt "0.2.1"
(defproject no.nsd/clj-jwt "0.3.0"
:description "A Clojure library to fetch json web keys and validate json web tokens. Wraps Buddy."
:url "https://gitlab.nsd.no/clojure/clj-jwt"
:license {:name "Eclipse Public License"
......
......@@ -133,14 +133,14 @@
(s/fdef unsign
:args (s/cat :token ::jwt
:jwks-url ::jwks-url)
:args (s/cat :jwks-url ::jwks-url
:token ::jwt)
:ret ::claims)
(defn unsign
"Given token, jwks-url, and optionally opts validates and returns the claims
"Given jwks-url, token, and optionally opts validates and returns the claims
of the given json web token. Opts are the same as buddy-sign.jwt/unsign."
([token jwks-url]
(unsign token jwks-url {}))
([token jwks-url opts]
([jwks-url token]
(unsign jwks-url token {}))
([jwks-url token opts]
(jwt/unsign token (partial resolve-key jwks-url) (merge {:alg :rs256} opts))))
......@@ -63,27 +63,27 @@ vLu9XxKFHYlWPccluz3pqDfaGNPO12968DAldwvAV6hTGgx7oMaNPu0UltgD/aaj
(deftest unsign-jwt
(testing "Unsigns jwt and returns payload"
(is (= (with-redefs [clj-jwt/public-keys (atom {"test-key" ec-pubkey})]
(clj-jwt/unsign signed-jwt (resource "jwks.json")))
(clj-jwt/unsign (resource "jwks.json") signed-jwt))
jwt-payload)))
(testing "Fails if key referenced in jwt header is not found"
(is (thrown? Exception
(with-redefs [clj-jwt/public-keys (atom {})]
(clj-jwt/unsign signed-jwt (resource "jwks-other.json")))))))
(clj-jwt/unsign (resource "jwks-other.json") signed-jwt))))))
(deftest verify-jwt
(testing "Unsigns jwt and returns payload"
(is (= (with-redefs [clj-jwt/public-keys (atom {"test-key" ec-pubkey})]
(clj-jwt/unsign signed-jwt (resource "jwks.json")))
(clj-jwt/unsign (resource "jwks.json") signed-jwt))
jwt-payload)))
(testing "Refetches keys if no matching keys found"
(is (= (with-redefs [clj-jwt/public-keys (atom {})]
(clj-jwt/unsign signed-jwt (resource "jwks.json")))
(clj-jwt/unsign (resource "jwks.json") signed-jwt))
jwt-payload)))
(testing "Fails if key referenced in jwt head is not found"
(is (thrown? Exception
(with-redefs [clj-jwt/public-keys (atom {})]
(clj-jwt/unsign signed-jwt (resource "jwks-other.json")))))))
(clj-jwt/unsign (resource "jwks-other.json") signed-jwt))))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment