Here it is folks, a nice, clean MAuth client done in the simplest and most minimal way possible, for your Clojure application.
There are a minimal set of dependencies (Bouncy Castle isn't one of them!), it is fast, and can even be used as middleware for securing your applications.
You do NOT need to jump through hoops to use this library. Simple is as simple does.
Either use the built jar, or
lein jar to build one based on source.
First, you need to give the library your
MAuth Private Key and
MAuth Service URL.
You can do this by defining the environment variables
Or, you may do this programmatically by calling
credentials/define-credentials with the respective parameters.
You can make an MAuth call by requiring the
request namespace and either doing
put! with the necessary parameters.
These are the most common verbs in use out there, but its easy to extend support to other verbs as needed (PRs welcome!).
If the verb you want isn't in the namespace, you can also make a call to
request/make-request and specify your action directly.
It is possible to do a macro for this stuff, but I am not a big fan of that approach for this case, because you lose IDE support, and it will appear as undefined there, which is annoying.
Full example (standard usage):
(:require [clojure-mauth-client.request :as mauth]
[clojure.data.json :as json]))
;either your app has to have the APP_UUID, MAUTH_KEY, and MAUTH_SERVICE_URL predefined in env...
;or... you can call define-credentials...
;do the call!
(-> (mauth/get! "https://www.mdsol.com" "/api/v2/testing.json")
(:require [clojure-mauth-client.middleware :refer [wrap-mauth-verification]]))
Yep, it really is that simple!
Recently, it has come to my attention that cloudflare or cloudfront URLs (ie. api-gateway) were not supported due to SNI configuration in the load balancer. Welp, not anymore!
To do your calls with SNI, pass
:with-sni? true to your calls.
(mauth/get! "https://www.mdsol.com" "/api/v2/testing.json" :with-sni? true)
Tests can be run using
Contributions are welcome by Pull Request, and we welcome and encourage that!
Copyright © 2018 Medidata Solutions
This Library is licensed under the MIT licensing terms. See LICENSE.md for details