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 pseudocode Also written as pseudo-code. A method of writing up a set of instructions for a computer program using plain English. This is a good way of planning a program before coding. 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