drewc / ecm-user

A user authorisation front-middle-backend For The Web!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ECM User: Users and Login for a webapp

The idea is that an application has users. This is the meeting spot for all ECM application and system pieces that (hopefully) cover the needs. Backwards compatible!

Contents

The User abstraction

In general all users are, well, users. So the supertype of user, which is not a superuser but a superclass as it were, is outlined Here

The Login server

The idea is to keep it all in one place.

Configuration

The config for the old version, and therefore our version, is stored in ~/.ecm/json.

(import :std/text/json)
(export #t)

(def conf #f)

(def (update-conf (fname "~/.ecm/ecm.json"))
  (set! conf (call-with-input-file fname read-json)))

(def (conf-value key (conf conf) reload: (r? #f))
  (def rest [])
  (when (list? key) (set! rest (cdr key)) (set! key (car key))) 
  (when (or (not conf) r?) (update-conf))
  (let ((res (hash-ref conf key (void))))
    (if (and (not (null? rest)) (hash-table? res))
      (conf-value rest res)
      res)))

Database

There are many ways in which the interaction with the database is driven by users and it matters to the database!

Because of that there’s a lot dedicated.

Build

  ;; -*- Gerbil -*-

  (import :std/build-script)

  (defbuild-script
    '("login/conf"
      "login/database"
      "login/types"
      "login/api"
      "login/handler"
      "login/reset-password"
       (exe: "login")
      "user/database/interface"
      "user/database/pool"
      "user/database"
      "user/entity"
))

Package

(package: ecm
 ;; depend: ("github.com/drewc/ftw")
)

HACKING

(begin
  (import :ecm/login/handler
          :ecm/login/conf
          :ecm/login/reset-password
	  :ecm/login/database :std/net/httpd :std/contract :std/net/httpd/mux)
(import
  :std/pregexp :std/net/smtp :std/net/httpd/mux :std/net/httpd :std/net/uri
  :std/contract :std/text/json :std/misc/ports :std/text/utf8
  :ecm/login/database :ecm/login/handler)
(update-conf) (create-reset-token "me+ecm@drewc.ca"))



(def server (run-login-server "0.0.0.0:8080"))

About

A user authorisation front-middle-backend For The Web!

License:MIT License


Languages

Language:Scheme 43.7%Language:HTML 40.1%Language:JavaScript 16.1%