###やりたいこと###
CookieのName
と値を変えたり,httponly
をt
にしたりしたい。
###app.lisp###
とりあえずapp.lisp
のbuilder
内部の<clack-middleware-session>
が,外部からいじれる部分だろうと思って<clack-middleware-session>
をsuperclassとしたclassを定義してみました。
(defclass <myapp-clack-session-state-cookie> (<clack-session-state-cookie>)
((session-key :initform :myapp.session
:accessor session-key)
(secure :initform nil
:accessor secure)
(httponly :initform t
:accessor httponly)))
(defclass <myapp-clack-middleware-session> (<clack-middleware-session>)
((state :initform (make-instance '<myapp-clack-session-state-cookie>)
:accessor state)))
(builder
(<clack-middleware-static>
:path (lambda (path)
(if (ppcre:scan "^(?:/images/|/css/|/js/|/robot\\.txt$|/favicon.ico$)" path)
path
nil))
:root *static-directory*)
(if (productionp)
nil
(make-instance '<clack-middleware-accesslog>))
(if (getf (config) :error-log)
(make-instance '<clack-middleware-backtrace>
:output (getf (config) :error-log))
nil)
;; <clack-middleware-session>
<myapp-clack-middleware-session> ;;ここだけ書き換え
(if (productionp)
nil
(lambda (app)
(lambda (env)
(let ((datafly:*trace-sql* t))
(call app env)))))
*web*)
なんてしてみたものの変化なし。
試しに直にclack.session.state
のsession-key
の値を書き換えたらcookieの値も変わりました。
(defclass <clack-session-state> ()
((session-key :type keyword
:initarg :session-key
:initform :myapp.session ;; :clack.session
:accessor session-key)
(sid-generator :type function
:initarg :sid-generator
:initform
#'(lambda (&rest args)
@ignore args
(clack.util:generate-random-id))
:accessor sid-generator)
(sid-validator :type function
:initarg :sid-validator
:initform
#'(lambda (sid)
(not (null (ppcre:scan "\\A[0-9a-f]{40}\\Z" sid))))
:accessor sid-validator)))
=> MYAPP.SESSION e3d5067aceb466a9b01a04deb2170137c8bec3b0
CLOS自体も大分忘れてるので混乱中…
とりあえずもうちょっとソース読み込みます…
###追記(2015-01-05-1310)###
builderを以下の様に書き換えたらできました。
(builder
(<clack-middleware-static>
:path (lambda (path)
(if (ppcre:scan "^(?:/images/|/css/|/js/|/robot\\.txt$|/favicon.ico$)" path)
path
nil))
:root *static-directory*)
(if (productionp)
nil
(make-instance '<clack-middleware-accesslog>))
(if (getf (config) :error-log)
(make-instance '<clack-middleware-backtrace>
:output (getf (config) :error-log))
nil)
;; <clack-middleware-session>
(<myapp-clack-middleware-session>
:state (make-instance '<myapp-clack-session-state-cookie>))
;; <myapp-clack-middleware-session>
(if (productionp)
nil
(lambda (app)
(lambda (env)
(let ((datafly:*trace-sql* t))
(call app env)))))
*web*)
<myapp-clack-middleware-session>
の:initform
が効いてない??
とりあえず出来たけど疑問が残ってます。