work in progress: auth: simple implementation: class structure
This commit is contained in:
parent
84889bdede
commit
d24289abc3
4 changed files with 26 additions and 11 deletions
|
@ -6,30 +6,39 @@
|
||||||
(:core :scopes/core)
|
(:core :scopes/core)
|
||||||
(:util :scopes/util))
|
(:util :scopes/util))
|
||||||
(:export #:config #:setup
|
(:export #:config #:setup
|
||||||
|
#:simple-credentials
|
||||||
#:login))
|
#:login))
|
||||||
|
|
||||||
(in-package :scopes-auth)
|
(in-package :scopes-auth)
|
||||||
|
|
||||||
(defvar *authenticator* nil)
|
|
||||||
|
|
||||||
(defclass config (config:base)
|
(defclass config (config:base)
|
||||||
((admin-credentials :reader admin-credentials :initarg :admin-credentials)))
|
((admin-credentials :reader admin-credentials :initarg :admin-credentials)))
|
||||||
|
|
||||||
|
(defclass context (core:context)
|
||||||
|
((authenticator :initform (make-instance 'simple-authenticator))))
|
||||||
|
|
||||||
(defun setup (cfg)
|
(defun setup (cfg)
|
||||||
(let ((ctx (core:default-setup cfg))
|
(let* ((ctx (core:default-setup cfg 'context)))
|
||||||
(*authenticator* (make-instance 'simple-authenticator)))
|
|
||||||
ctx))
|
ctx))
|
||||||
|
|
||||||
;;;; simple / basic auth service implementation
|
;;;; simple / basic auth service implementation
|
||||||
|
|
||||||
(defclass simple-authenticator () ())
|
(defclass simple-authenticator ()
|
||||||
|
((principals)))
|
||||||
|
|
||||||
(defclass simple-credentials () ())
|
(defclass simple-credentials ()
|
||||||
|
((login-name)
|
||||||
|
(password)))
|
||||||
|
|
||||||
(defclass internal-principal () ())
|
(defclass principal ()
|
||||||
|
((identifier)
|
||||||
|
(credentials)
|
||||||
|
(full-name)
|
||||||
|
(primary-address)
|
||||||
|
(primary-role)))
|
||||||
|
|
||||||
(defun authenticate (cred)
|
(defun authenticate (cred)
|
||||||
(make-instance 'internal-principal))
|
(make-instance 'principal))
|
||||||
|
|
||||||
;;;; login entry point
|
;;;; login entry point
|
||||||
|
|
||||||
|
@ -37,3 +46,8 @@
|
||||||
(let ((srv (core:find-service :auth)))
|
(let ((srv (core:find-service :auth)))
|
||||||
(util:lgi cred (admin-credentials (core:config srv)))))
|
(util:lgi cred (admin-credentials (core:config srv)))))
|
||||||
|
|
||||||
|
;;;; auxiliary functions
|
||||||
|
|
||||||
|
(defun digest (pw)
|
||||||
|
(ironclad:digest-sequence
|
||||||
|
:sha3/256 (flexi-streams:string-to-octets pw :external-format :utf8)))
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
:version "0.0.1"
|
:version "0.0.1"
|
||||||
:homepage "https://www.cyberconcepts.org"
|
:homepage "https://www.cyberconcepts.org"
|
||||||
:description "Authentication services"
|
:description "Authentication services"
|
||||||
:depends-on (:scopes)
|
:depends-on (:scopes
|
||||||
|
:flexi-streams :ironclad)
|
||||||
:components ((:file "auth"))
|
:components ((:file "auth"))
|
||||||
:long-description "scopes framework: authentication services."
|
:long-description "scopes framework: authentication services."
|
||||||
;;#.(uiop:read-file-string
|
;;#.(uiop:read-file-string
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
;;;; cl-scopes/lib/auth/test/config
|
;;;; cl-scopes/lib/auth/test/etc/config
|
||||||
;;;; use: `(let ((t:*current-system* :scopes-auth) ...)
|
;;;; use: `(let ((t:*current-system* :scopes-auth) ...)
|
||||||
;;;; `(load (t:test-path "config" "etc")))`
|
;;;; `(load (t:test-path "config" "etc")))`
|
||||||
;;;; from scopes-auth/test
|
;;;; from scopes-auth/test
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
;;; cl-scopes/test/config-postgres.lisp
|
;;; cl-scopes/test/etc/config-postgres.lisp
|
||||||
;;; use: `(load "test/...")` from package scopes/test-storage
|
;;; use: `(load "test/...")` from package scopes/test-storage
|
||||||
|
|
||||||
(in-package :scopes/test-storage)
|
(in-package :scopes/test-storage)
|
||||||
|
|
Loading…
Add table
Reference in a new issue