     (dosync (alter tokens assoc simple-token token-contents))
     simple-token))
 
-(def jws-token-backend
-  (jws-backend {:secret "secret" :options {:alg :hs512}}))
+(defn jws-token-backend [secret]
+  (jws-backend {:secret secret :options {:alg :hs512}}))
 
 (defn simple-token-fn [tokens]
   (fn [req token]

  (token-auth-mw [this]
    (fn [handler]
      (wrap-authentication
       handler jws-token-backend
       (token-backend {:authfn (simple-token-fn tokens)}))))
  (auth-credentials-response [this req]
    (let [user          (:identity req)

(defn basic-backend [user-info]
  (http-basic-backend {:authfn (basic-auth user-info)}))

(defn create-token [secret user]
  (let [stringify-user
        (-> user
            (update-in [:username] str)
            (update-in [:email] str)
            (assoc     :exp (time/plus (time/now) (time/years 5))))
        token-contents
        (select-keys stringify-user [:permissions :username :email :id :exp])]
    (jws/sign token-contents secret {:alg :hs512})))

(defn create-simple-token [tokens user]
  (let [stringify-user
