mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 10:40:45 -08:00
60 lines
2.1 KiB
Common Lisp
60 lines
2.1 KiB
Common Lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;; CLOG - The Common Lisp Omnificent GUI ;;;;
|
|
;;;; (c) 2020-2022 David Botton ;;;;
|
|
;;;; License BSD 3 Clause ;;;;
|
|
;;;; ;;;;
|
|
;;;; clog-auth.lisp ;;;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; CLOG-Auth an authorization abstraction for CLOG
|
|
|
|
(mgl-pax:define-package :clog-auth
|
|
(:documentation "CLOG-AUTH an authorization abstraction for CLOG")
|
|
(:use #:cl #:clog #:mgl-pax))
|
|
|
|
(cl:in-package :clog-auth)
|
|
|
|
(defsection @clog-auth (:title "CLOG Auth Objects")
|
|
"CLOG-AUTH - authorization abstraction for CLOG"
|
|
(get-authentication-token function)
|
|
(store-authentication-token function)
|
|
(remove-authentication-token function))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Implementation - clog-auth
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defparameter *clog-auth-key* "clog-auth-token"
|
|
"Key used for local storage of authentication token")
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; get-authentication-token ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defun get-authentication-token (body &key auth-path)
|
|
"Retrieve the stored authorization token"
|
|
(let ((token (storage-element (window body) :local *clog-auth-key*)))
|
|
(print token)
|
|
(when (equalp token "null")
|
|
(setf token nil))
|
|
(unless token
|
|
(when auth-path
|
|
(url-assign (window body) auth-path)))
|
|
token))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; store-authentication-token ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defun store-authentication-token (body token)
|
|
(setf (storage-element (window body) :local *clog-auth-key*) token))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; remove-authentication-token ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defun remove-authentication-token (body)
|
|
(storage-remove (window body) :local *clog-auth-key*))
|
|
|
|
|
|
|