3.2.11 - Authentication routines (Python)

3.2.11 - Authentication routines (Python)

Authentication checks a claimed identity before access is granted. You will implement a simple Python username/password check and distinguish it from validating the shape of an input.

Checking identity

An authentication routine compares supplied credentials with the credentials expected for an account.

Authentication

Checking whether a user is who they claim to be, for example through a username and matching password.

A username identifies the claimed account; the password provides the secret checked for that account. In a simple one-account example, both supplied values must match. A correct username with a wrong password is insufficient, as is a correct password with a different username.

Validation asks whether input meets a rule. A six-character password can pass a length check and still fail authentication because it is not the account's password. Authentication does not prove that all the user's other entered data is valid either.

AQA's simple examined routines use plain-text usernames and passwords; implementing password encryption is not required. The dummy classroom credentials below demonstrate the comparisons. Real systems need suitable protection of stored credentials and access; hard-coding a plain-text password is not a production storage recommendation.

Writing a username and password check

Use and to require the username and password comparisons to be true together.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account