ported the auth logic

should more or less work, but i still have to test it