January 2018
Intermediate to advanced
336 pages
7h 56m
English
Ideally, the Auth service must be backed by a persistent store to keep the users, roles, and the secret key for the application. For the sake of simplicity of the example, create a sample in-memory database in the helping-hands.auth.persistence namespace, as follows:
(ns helping-hands.auth.persistence "Persistence Implementation for Auth Service" (:require [agynamix.roles :as r] [cheshire.core :as jp]) (:import [java.security MessageDigest]))(defn get-hash "Creates a MD5 hash of the password" [creds] (.. (MessageDigest/getInstance "MD5") (digest (.getBytes creds "UTF-8"))))(def userdb ;; Used ony for demonstration ;; TODO Persist in an external database (atom {:secret nil :roles {"hh/superadmin" ...Read now
Unlock full access