A dirt-simple URL shortener.
This app assumes apache- (or nginx-) level authentication. We're using apache ldap auth to integrate with our ActiveDirectory server and a set of rewrite rules to ensure user credentials are NEVER passed over non-HTTPs connections. The virtualhost containers look like:
<VirtualHost *:80> ServerName example.com DocumentRoot /your/railsroot/public RewriteEngine On RewriteRule ^/$ https://example.com/ [R=302,L] RewriteRule ^/(url|user|metric|redirector|preview) https://example.com/$1 [R=302,L] </VirtualHost> <VirtualHost *:443> ServerName example.com DocumentRoot /your/railsroot/public SSLEngine On # SSL cert / key config stuff here. <LocationMatch "^/url|user|metric|redirector|preview"> # Your auth config here. </LocationMatch> </VirtualHost>
This sets up the app so that access to “/” redirects you to an HTTPS connection that'll attempt authentication. Shortened URLs are available via http:// or https://, authenticated or not.
You can use any apache-level authentication module in the LocationMatch container above, even good ol' htpasswd basic auth.
Dan Collis-Puro: firstname.lastname@example.org
brkmn is licensed under the terms of Rails 3.2 itself - the MIT license: www.opensource.org/licenses/mit-license.php
2012 President and Fellows of Harvard College