Created authentication middleware.