Hacked up json authentication. Needs some refactoring, it's getting pretty gross.