Skip to content

Instantly share code, notes, and snippets.

@simonerni
simonerni / csrf-protection-cloudflare-worker.js
Created July 7, 2018 14:52
Protect any origin from CSRF by checking if the Origin/Referer header match the Host header for "unsafe" methods.
/**
* GET and HEAD requests are by definition idempotent and should be handled by the origin as such. Thus, we can safely pass them on without further origin / referer checks.
*/
const safeMethods = ['GET','HEAD'];
const allowedMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE'];
addEventListener('fetch', event => {
event.respondWith(verifyAndFetch(event.request))
})
@simonerni
simonerni / Disclaimer
Created February 26, 2018 16:21
Video Lecture Downloader ETHZ
Original Author: Basil Fürer, just redistributing here for convenience.
@simonerni
simonerni / fluent.conf
Last active January 13, 2018 18:34
Fluentd Icecast configuration - optimized for Google Cloud Stackdriver
<source>
type tail
path /var/log/icecast2/access.log
pos_file /var/lib/google-fluentd/pos/icecast-access.log.pos
tag icecast-access
format /^(?<message>(?<host>[^ ]*) - - \[(?<time>[^\]]*)\] \"(?<request_type>[^ ]*) \/(?<request_uri>[^ ]+) (?<request_protocol>[^ ]*)\" (?<status_code>[^ ]*) (?<bytes>[^ ]*) \"(?<referrer>[^\"]*)\" \"(?<agent>[^\"]*)\" (?<duration>[^ ]*).*)/
time_format %d/%b/%Y:%H:%M:%S %z
</source>
<source>
type tail

Keybase proof

I hereby claim:

  • I am simonerni on github.
  • I am simonerni (https://keybase.io/simonerni) on keybase.
  • I have a public key ASAGYDz0z6Ub6tuogrByfZ3eXi-grbsC6UfA6jvVbnC2GAo

To claim this, I am signing this object: