Authentication middleware for connect.