Passing encypted password inside WebUI.authenticate

I am using the method below to access my URL. I have to use this method as I am required to authenticate to this URL.

WebUI.authenticate(GlobalVariable.my_url, ‘MJones’,‘mypassword123’, 10)

I want to provide the password in encrypted form. I have used the “Encrypt Text” feature within the Katalon Help menu and obtained an encrypted string but I cannot use this string with the method above.

The authentication box is the generic box that firefox and chrome presents to the user and so is not an object of my webpage.

Surely it must be possible to provide the password within the WebUI.authenticate method in encrypted form?

1 Like

Hello,

actually, if you use Basic authentication, credentials are not encrypted, but encoded (using Base64). So it is very easy to decode it. I can show you a sample code, but IMO it is redundant.

Edit: Working code:

String encPwd = "a2F0YWxvbjpzdHVkaW8="
String decPwd = new String(Base64.getDecoder().decode(encPwd))

String url = "https://" + decPwd + "@httpbin.org/basic-auth/katalon/studio"

WebUI.openBrowser(url)

Thanks for the reply Marek, it is appreciated.

Best wishes, Martin

Hi Marek,

Thanks … But how to hide or encrypt the password in Katalon HTML report.

01:58:17.493 PASSED Browser is opened with url: https://katalon:studio@httpbin.org/basic-auth/katalon/studio

Once again - the credentials are encoded, not encrypted. Even if you had your password encrypted, you’d have to decrypt it at some point prior to using it in your Basic auth.

Encoded form can be easily decoded without knowing or having anything else.

Hi Marek, How to hide the user name and password in the reports and log file.

Extract the code into a custom method.

public static void login() {
	String encPwd = "a2F0YWxvbjpzdHVkaW8="
	String decPwd = new String(Base64.getDecoder().decode(encPwd))
	
	String url = "https://" + decPwd + "@httpbin.org/basic-auth/katalon/studio"

	// this is logged
	WebUI.openBrowser('')
    // this is not
	DriverFactory.getWebDriver().navigate().to(url)
}

And call it in your test case.

20181223-104325

Thanks Marek …:wink: Appreciate it.