With this library you can read and write sessions generated by Ruby on Rails applications in version 4.x.
- compatiblity with Clojure >= 1.9
- fewer dependencies (target goal is 0 dependencies)
- CI setup via GH actions
- no reflection warnings
To install, add the following to your project :dependencies
:
[lukaszkorecki/rails-session-clojure "0.3.0-SNAPSHOT"]
Secret key base can usually be found in config/secrets.yml
file
in the Rails app.
(def secret-key-base "abcd")
Pass in the secret to create-session-decryptor
and that will return
a function that can be used for decrypting.
(def decrypt-session
(create-session-decryptor secret-key-base))
Pull the right cookie value from HTTP headers and pass that to the decryptor. That will return a map structure corresponding a Ruby Hash that was saved in the Rails session.
(decrypt-session cookie-value)
;; => {"session_id" "cddf4f5a44da3f627fd186d3fc47a7ef",
;; "foo" "bar",
;; "_csrf_token" "6qbIbpxXn8sZnGSCV7SgvX+0lhzUXS0J51goFX6mJxY="}
If non-standard signature/encryption salts were used, you can pass them in
as additional arguments to create-session-decryptor
.
In a Rails app you will find those values in
config.action_dispatch.encrypted_signed_cookie_salt
and
config.action_dispatch.encrypted_cookie_salt
variables.
(def decrypt-session
(create-session-decryptor secret-key-base custom-signature-salt custom-encryption-salt))
Copyright © 2015 Michał Kwiatkowski Copyright © 2020 Łukasz Korecki
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.