Ugly but working authorization