Adding Auth Mechanism

Not 100% tested, TODO need to write more test cases