Add authentication checks (fixes #1)