Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] enhance print-string-secrect-key-deprecation #415

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions ring-core/src/ring/middleware/session/cookie.clj
Expand Up @@ -56,9 +56,11 @@
(String. (.doFinal cipher (byte-array data)))))

(defn- print-string-secret-key-deprecation []
":ver - Get the current ring version."
(binding [*out* *err*]
(println "WARNING: The secret key for the session cookie store should be a"
"byte array.\nString secret keys have been deprecated.")))
(let [ver (System/getProperty "ring.version")]
(println "WARNING (library 'ring' " ver "): The secret key for the session cookie store should be a"
"byte array.\nString secret keys have been deprecated."))))

(defn- get-secret-key
"Get a valid secret key from a map of options, or create a random one from
Expand Down
11 changes: 6 additions & 5 deletions ring-core/test/ring/middleware/session/test/cookie.clj
Expand Up @@ -72,8 +72,9 @@
{:foo now}))))

(deftest cookie-session-deprecation-warning
(is (= (with-out-str
(binding [*err* *out*]
(cookie-store {:key "0123456789abcdef"})))
(str "WARNING: The secret key for the session cookie store should be a"
" byte array.\nString secret keys have been deprecated.\n"))))
(let [ver (System/getProperty "ring.version")]
(is (= (with-out-str
(binding [*err* *out*]
(cookie-store {:key "0123456789abcdef"})))
(str "WARNING (library 'ring' " ver "): The secret key for the session cookie store should be a"
" byte array.\nString secret keys have been deprecated.\n")))))