[1.7.x] Fixed #22362 -- Improved AuthenticationMiddleware assertion message.

Thanks Keryn Knight.

Backport of 246face209 from master