adds middleware for authentication