Authorization complete

WIP, still needs lots of polishing