Skip to content

ShapeOfMatter/WebTrackerPOC

Repository files navigation

WebTrackerPOC

This was intended to demonstrate that a pure Haskell web service was a viable option. While a lot more could be done even within this limited goal, it's unlikly I'll return to do any further work in this repo.

Goals

  • User associates a (potentially new) username with a browser-session (cookie). ✓
  • Requests to a particular address have the http-referer logged with the corrisponding username. ✓

Next Steps

  • Confirm that a webpage can't fire spoofed "Referer" (and/or "Origin") headers from an unconsenting browser.
  • Decide if Persistent (a Template-Haskell based Domain Specific Language for talking to databases) would be more appropreate than Hasql.
  • Decide if Yesod (a heavier, more complete Haskell web framework) would be more approoreate than Scotty
  • Generally refactor stuff to have a flatter, more idiomatic layout.
  • Consider building our own Monad stacks, or use existing stacks better for validation and database interaction.
  • Move type changes to the perifiery, and make them automatic (using type classes) where possible. Have more of our own types for business atoms.
  • Maybe have fewer in-line type declarations, and let function declarations be more vague (via typeclases).
  • Use DB transactions.

Installation

A brand new ubuntu-style linux box is assumed.

Some of the installation steps are very ram-hungry. On smaller servers I suggest using the instructions here to give yourself extra swap space (try 4G).

This is all taken from a tutorial here.
Install Nix blindly, or figure out the proper secure way of doing it.

curl https://nixos.org/nix/install | sh

There will be a second step, which the output of the above should promt you for. something like:

. /home/ubuntu/.nix-profile/etc/profile.d/nix.sh

Next use nix to set up some Haskell specific utilities.

nix-env --install cabal2nix
nix-env --install nix-prefetch-git
nix-env --install cabal-install

Download and build the project

git clone https://github.com/ShapeOfMatter/WebTrackerPOC.git
cd WebTrackerPOC/
cabal2nix . > default.nix
nix-build unpinned.nix

You'll need a config file. For now it has to be named "defaults.config", and it should go right in the WebTrackerPOC directory.

[DatabaseConnectionPool]
host = "example.com"
port = 5432
user = "example"
password = "xxx"
database = "example"
maxconnections = 5
maxidleseconds = 60
[SiteSettings]
baseurl = http://example.com
port = 80

Finally, you can set the server running just by calling:

result/bin/poc_scotty_server

But remember to disown the process from your shell before loggin out.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published