Bobcares

Apache JMeter Basic Authentication | Set Up Guide

by | Aug 30, 2023

Learn more about Apache JMeter Basic Authentication from our experts. Our Apache Support team is here to help you with your questions and concerns.

Apache JMeter Basic Authentication | Set Up Guide

In the world of performance testing, JMeter is a powerful tool. It helps evaluate the functional behavior of web services.

However, testers tend to run into situations where the web services being tested are protected by HTTP Basic Authentication.

Apache JMeter Basic AuthenticationIf you are in a similar spot, our experts have your back.

Before we dive into the implementation details, let’s take a closer look at Basic Authentication. It is a simple access-control method that helps us secure a web resource. It includes an HTTP header sent by the client.

This header contains the credentials as a Base64 string. It contains the username and password delimited by a single colon.

Furthermore, Basic Authentication is used when logins are requested in the browser’s window.

Hence, if we start a JMeter test on a secured web response, we will get HTTP 401 as the response.

Additionally, we will get a “WWW-Authenticate” response header that lets us know the authentication type required by the server.

How to implement Basic Authentication in JMeter

Method 1: Authorization Header Injection

The simplest way to offer credentials is by embedding them directly into the request header.
JMeter does this via the HTTP Header Manager component as seen below:

  1. First, we have to place the HTTP Header Manager under the desired HTTP Request component.
  2. Then, head to the manager’s configuration tab and add an entry with our authentication details. Additionally, name it “Authorization.”
  3. Next, we have to encode our credentials with online tools. We have to add the prefix “Basic” before the encoded string.
  4. When executed smoothly, our server will respond with a cheerful HTTP 200, signifying success.

Method 2: JSR223 PreProcessor Magic

Alternatively, we can use the JSR223 PreProcessor to encode the credentials. Here are the steps:

  1. First, we have to add a JSR223 PreProcessor before our HTTP Header Manager.
    We can run a script at runtime with this component.

  2. Then, we have to define our username and password variables in User Defined Variables.
  3. Finally, we have to set the Authorization header to use the encoded credentials in the HTTP Header Manager. This makes it easy to change credentials in our user-defined variables.

Method 3: Using HTTP Authorization Manager

JMeter also lets HTTP Authorization Manager handle credentials.

This component lets us offer credentials for different domains and authentication protocols.

  1. First, we have to embed the HTTP Authorization Manager within the Thread Group and before to the HTTP Request component.
  2. Then, we have to add our username and password in its configuration tab.
  3. Furthermore, variables from the User Defined Variables component can be used here too.
  4. Then, we have to make sure we choose BASIC as the mechanism.

At the end of the day, we can choose one of the above options to help JMeter deal with Basic Authentication.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Today, our Support Techs demonstrated how to set up Basic Authentication in Apache JMeter.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF