easoncxz / twitanalysis

Dig your Twitter data
https://easoncxz.github.io/twitanalysis
Other
1 stars 0 forks source link

Investigate HTTP(?) sessions with Scotty/WAI #5

Closed easoncxz closed 4 years ago

easoncxz commented 4 years ago

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:

easoncxz commented 4 years ago

Reading list:

easoncxz commented 4 years ago

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/ )

easoncxz commented 4 years ago

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.

easoncxz commented 4 years ago

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: