Closed easoncxz closed 4 years ago
Reading list:
wai-session
Lol, this old scotty-session
package on Hackage is only <100 lines long:
Surely there's a way to use this conveniently, either via extra-deps:
in Stack, or straight-up copy-pasting it and committing it into my repo. It's BSD-3 licensed, so we're all-good.
Cheatsheet:
$ stack ghci --package scotty-session
(cf. https://www.fpcomplete.com/haskell/tutorial/stack-script/ )
I forked the repo for now:
Not sure whether I should go down this rabbit hole right this moment. Publishing updates to a Hackage library, even an ad-hoc Github-hosted one, probably requires me to know how to use cabal-install, which I still don't really.
Might be easier/safer to just check-in a copy and tweak things until it works.
Turns out vendoring a copy was a rather trivial process: commit 5aa6458 does it easily.
I just had to add a couple of dependencies; most were obvious, and the only potentially conflicting package was crypto-api
, which scotty-session
wanted, but has clashing module-names as cryptonite
, which I'm not sure why I had. So I just removed cryptonite
and everything worked.
Then it was a matter of piecing together Blaze and Scotty APIs to do something sensible. Commit 2fa286e did so.
Relevant reference docs:
type Html = Markup
alias: https://www.stackage.org/haddock/lts-16.12/blaze-html-0.9.1.2/Text-Blaze-Html.html#t:HtmlSet-Cookie
header, to read about HttpOnly
and Secure
: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie<form>
elements (has a nice example): https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form<input type="submit">
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit
The plan is to do OAuth 1.0a request-signing on my Haskell backend, so that I can have the prospects of hosting my app somewhere and let people use it, without them abusing my OAuth Consumer credentials (which would be the case if I just served them out to the frontend-app).
Plan: