The function of structural components of programs - EdexcelImplementing authentication

Programs are designed and implemented using common building blocks, known as programming constructs. These constructs are sequence, selection and iteration and they form the basis for all programs.

Part ofComputer ScienceApplication of computational thinking

Implementing authentication

Authentication in computer systems is essential to ensure that only users who have permission can access information, resources or programs. The first step in authentication is to verify that the user is who they claim to be by checking their user ID and password. Authentication keeps systems secure by preventing unauthorised access and protects sensitive data.

Authentication methods

Common authentication methods include user ID and password, two-factor authentication and biometric authentication.

A user ID and password combination is the most common method of authentication. It checks that the user ID exists and that the password matches what is stored.

Two-factor authentication adds an additional step such as sending a code to a phone or email address, which must be entered.

Biometric authentication uses fingerprint or face recognition to allow the user access to the system.

Implementing basic authentication

Example

This example uses a 2D array in to store user IDs and passwords.

SET users TO [ ["amy", "peach123"], ["eira", "grape456"], ["suraj", "melon789"] ] # Ask the user to log in with username and password OUTPUT "Enter your user ID: " INPUT username OUTPUT "Enter your password: " INPUT password SET access_granted TO False # Check if the username exists and the password matches # If both are correct, access is granted FOR EACH user IN users IF user[0] = username AND user[1] = password THEN SET access_granted TO True ENDIF ENDFOR IF access_granted = True THEN OUTPUT "Access granted." ELSE OUTPUT "Access denied." ENDIF