Multi factor authentication which are done by One time password, those can be automated using Cometa
-
MFA (Multi Factor Authentication) Multi-factor authentication (MFA, two-factor authentication, or 2FA, along with similar terms) is an electronic authentication method in which a user is granted access to a website or application only after successfully presenting two or more pieces of evidence (or factors) to an authentication mechanism.
Source Wikipedia
-
OTP (One Time Password) A one-time password (OTP), also known as a one-time PIN, one-time authorization code (OTAC) or dynamic password, is a password that is valid for only one login session or transaction, on a computer system or other digital device.
OTP generation algorithms make use of pseudorandomness to generate a shared key.
Source: Wikipedia
The automation of two-factor authentication with Cometa requires two steps.
-
Step 1: (Prerequisite) Create an account and obtain the MFA secret key. If you already have an account, you can use that. Next, follow the provided links to set up MFA and obtain the secret key from any one of the multi-factor authentication providers. (This requires at least one MFA setup), (This requires at least one MFA).
1. Gitlab Set up Multi-Factor Authentication (MFA) in our GitLab.
2. Google MFA Create an account at Google then get a secret key. Note: You have the option to choose any other MFA provider based on your needs
Get verification code Once you are asked to scan the OR code, do not do that. Instead, get the secret key and follow the steps below:-
Create a small Python script using the code below.
import pyotp # i.e 'HHHH LLLL KKKK JJJJ LLLL DDDD DDDD DDDD' or ABCDEFGHIJKLMNOPQRSTUVWTUVWTUVW token = "YOUR CODE .... .... .... .... .... ...." token = token.replace(" ","") totp = pyotp.TOTP(token) otp = totp.now() print("OTP : ", otp)
-
Please install pyotp to run this code using the following command. (A machine with Python installed can run this code with the required library pyotp).
pip install pyotp
-
Replace "YOUR CODE ..." with your token/secret key.
-
Run the code; you will receive the OTP in the output.
Note: OTP will be valid for 60 seconds
For more information, use the pyAuth library to generate OTPs – see: https://github.com/pyauth/pyotp.
-
-
Step 2: Create Test Store the secret key in Cometa as a secret variable. Once the authentication token is stored, you can proceed to generate OTP using Cometa by following the next step.
Create one-time password of "{x}" digits using pairing-key "{value}" and save it to the encrypted variable "{variable_name}
Refer to the Create one-time password using Cometa
For illustration, you can automate the login screen of Cometa to test the functionality of the MFA automation feature
Steps to be automated
-
Fill Captcha
-
Select Login with Gitlab
-
Enter your "Gitlab_UserID"
-
Enter your "Gitlab_Password"
-
Click Sign In
-
Get OTP(Verification Code)
-
Enter OTP
-
Your will be logged into Cometa with MFA.
-
Create a feature in Cometa
-
Provide a feature name and description
-
Please follow the steps, as shown in the screenshot below
-