How does two-factor authentication work?

Technical