auth: starting with class definitions; add LICENSE (MIT)
This commit is contained in:
		
							parent
							
								
									5c1838b347
								
							
						
					
					
						commit
						fc23b47259
					
				
					 3 changed files with 41 additions and 4 deletions
				
			
		
							
								
								
									
										21
									
								
								LICENSE
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								LICENSE
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			@ -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)))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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")))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue