A Clojure library to handle validation of JWTs and signing claims using JSON Web Keys
clj-jwt is a powerful Clojure library that provides functionality for handling validation of JSON Web Tokens (JWTs) and signing claims using JSON Web Keys (JWKs). It wraps some of Buddy's functions for validating JWTs and signing claims, making it easier for developers to work with JWTs in their Clojure projects.
One of the key features of clj-jwt is its ability to fetch the public or private key from a JWKS (JSON Web Key Set) endpoint for validation or signing purposes. This abstraction allows developers to easily handle key management without worrying about the underlying implementation details.
To validate JWTs, developers can use the unsign function, which wraps Buddy's own unsign function. Alternatively, they can use the resolve-public-key function with the jws backend from Buddy Auth.
For signing claims and creating tokens, developers can use the sign function, which expects a JWKs URL/path, a key ID, the claims to sign, and optional options for the Buddy sign function.
To get started with clj-jwt, developers need to ensure they have Clojure installed. They can then clone the project and run Clojure Tools Deps targets. If they have rlwrap installed, they can use the clj command instead of clojure. It's important to include the dev alias when developing, as it provides all the necessary libraries.
For editor integration, developers can refer to the Clojure guides on editor integrations to connect or start a REPL integrated with their editor.
If developers are contributing code to the library, they can install their version of clj-jwt into their local Maven repository. They can also refer to their clj-jwt project in the other Clojure project's deps.edn file if they are using Clojure Tools Deps.
To make a new release of clj-jwt, developers need to have Leiningen installed. The project.clj file specifies a snapshot and release repository, and developers need to configure credentials for each of the repositories in their ~/.lein/credentials.clj file. They can then follow the provided points, such as running tests, bumping the version number, and publishing the release.
Overall, clj-jwt is a valuable Clojure library for developers who work with JWTs and need a convenient way to handle validation and signing using JSON Web Keys. Its integration with Buddy's functions and support for JWKS endpoints make it a powerful tool for managing JWTs in Clojure projects.