From fc23b4725902c3974ef59d8ce1b29cf937b40a6c Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Thu, 15 Aug 2024 09:59:12 +0200 Subject: [PATCH] auth: starting with class definitions; add LICENSE (MIT) --- LICENSE | 21 +++++++++++++++++++++ lib/auth/auth.lisp | 20 ++++++++++++++++++-- lib/auth/test/test-auth.lisp | 4 ++-- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ac7c3da --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (C) 2024 team@cyberconcepts.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/auth/auth.lisp b/lib/auth/auth.lisp index 3900ea0..6f0894a 100644 --- a/lib/auth/auth.lisp +++ b/lib/auth/auth.lisp @@ -5,17 +5,33 @@ (:local-nicknames (:config :scopes/config) (:core :scopes/core) (:util :scopes/util)) - (:import-from :scopes/web/dom #:div #:label) (:export #:config #:setup #:login)) (in-package :scopes-auth) +(defvar *authenticator* nil) + (defclass config (config:base) ((admin-credentials :reader admin-credentials :initarg :admin-credentials))) (defun setup (cfg) - (core:default-setup cfg)) + (let ((ctx (core:default-setup cfg)) + (*authenticator* (make-instance 'simple-authenticator))) + ctx)) + +;;;; simple / basic auth service implementation + +(defclass simple-authenticator () ()) + +(defclass simple-credentials () ()) + +(defclass internal-principal () ()) + +(defun authenticate (cred) + (make-instance 'internal-principal)) + +;;;; login entry point (defun login (cred) (let ((srv (core:find-service :auth))) diff --git a/lib/auth/test/test-auth.lisp b/lib/auth/test/test-auth.lisp index e6c645f..2b04d85 100644 --- a/lib/auth/test/test-auth.lisp +++ b/lib/auth/test/test-auth.lisp @@ -21,14 +21,14 @@ (let ((t:*current-system* :scopes-auth) (t:*test-suite* (t:test-suite "auth"))) (load (t:test-path "config" "")) - ;(unwind-protect + (unwind-protect (progn (core:setup-services) (let ((server (core:find-service :server)) (client (core:find-service :client))) (test-login))) (core:shutdown) - (t:show-result))) + (t:show-result)))) (deftest test-login () (let ((cred '(:login "admin" :password "secret")))