refactor authentication to library

authentication config for views