Basically working authentication implementation