                              [ssl :refer [wrap-ssl-redirect wrap-forwarded-scheme]])
             [hiccup.core :as h]
             [clj-time.core :as time]
+            [buddy.sign.jwt :as jwt]
             [buddy.sign.jwe :as jwe]
+            [buddy.core.nonce :as nonce]
             [buddy.auth :refer [authenticated? throw-unauthorized]]
             [buddy.auth.backends.token :refer [jwe-backend]]
             [buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]

  (route/resources "/")
  (route/not-found "Not Found"))

(def auth-backend (jwe-backend {:secret config/token-secret
                                :options {:alg :a256kw :enc :a128gcm}}))

(defn basic-authenticated?


(defn login
  [request]
  (let [username (get (:params request) "username")
        password (get (:params request) "password")
        valid? (some-> authdata
                       (get (keyword username))
                       (= password))]
    (if valid?
      (let [claims {:user (keyword username)
                    :exp (time/plus (time/now) (time/seconds 3600))}
            token (jwt/encrypt claims secret {:alg :a256kw :enc :a128gcm})]
        (ok {:token token}))
      (bad-request {:message "wrong auth data"}))))

