# Insert Basic Auth Header

**URL:** <https://community.f5.com/t/insert-basic-auth-header/70535>\
**Category:** Technical Forums\
**Tags:** application-delivery\
**Created:** [September 14, 2022, 7:28pm UTC](https://community.f5.com/t/insert-basic-auth-header/70535 "2022-09-14T19:28:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luis\_Melendrez](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@Luis\_Melendrez](https://community.f5.com/u/Luis_Melendrez)\
**Post date:** [September 14, 2022, 7:28pm UTC](https://community.f5.com/t/insert-basic-auth-header/70535/1 "2022-09-14T19:28:48Z")

</div>

Is there a way to insert basic auth header to the backend server?

clinet http request dont have the basic auth header and would like to build an irule so when the request is received, the proxy inserts the basic auth header with the proper credentials to the back end server.

Thanks

---

<div class="post-metadata">

**Author:** ![JoshBecigneul](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/joshbecigneul/32/19933_2.png) [@JoshBecigneul](https://community.f5.com/u/JoshBecigneul)\
**Post date:** [September 14, 2022, 8:32pm UTC](https://community.f5.com/t/insert-basic-auth-header/70535/2 "2022-09-14T20:32:02Z")

</div>

Hi&nbsp; @Luis_Melendrez

One thought that comes to mind is that you might be able to do a simple header injection via the HTTP profile or via an iRule. I do want to note that this design would allow any client to connect to your web application as whatever user is provided in the header, so it would not necessarily be much better than regular anonymous usage. Further, the password is only encoded with base64, so is essentially the same as clear text, you will want to use SSL/TLS to protect the communication.

To build the authorization string, combine the username and password, separated by a colon, and then base64 encode the whole string. For example RFC7617 shows the username Aladdin with password ‘open sesame’, which results in the base64 string&nbsp;QWxhZGRpbjpvcGVuIHNlc2FtZQ==. Be sure to come up with the value required for your implementation. [CyberChef](https://gchq.github.io/CyberChef) is a handy tool to do base64 operations.

In the HTTP profile, set the Request Header Insert value to:

Authorization Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

In an iRule, this might look like this. (I haven’t tested this):

```tcl
when HTTP_REQUEST_RELEASE {
    HTTP::header insert Authorization "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
}

```

Last note: that this method might not work if the application server is expecting to respond with a 401 error first and then have the user authenticate second. You would need additional logic in that case.

Thanks,

Josh Becigneul

---

<div class="post-metadata">

**Author:** ![Lebsack](https://avatars.discourse-cdn.com/v4/letter/l/3d9bf3/32.png) [@Lebsack](https://community.f5.com/u/Lebsack)\
**Post date:** [September 16, 2022, 3:50am UTC](https://community.f5.com/t/insert-basic-auth-header/70535/3 "2022-09-16T03:50:44Z")

</div>

A string of the hex digits that proves that the user knows a password. The algorithm encodes the username and password, realm, cnonce, qop, nc, and so on. It is described in detail in the specification.

---

<div class="post-metadata">

**Author:** ![Lebsack](https://avatars.discourse-cdn.com/v4/letter/l/3d9bf3/32.png) [@Lebsack](https://community.f5.com/u/Lebsack)\
**Post date:** [September 19, 2022, 3:08am UTC](https://community.f5.com/t/insert-basic-auth-header/70535/4 "2022-09-19T03:08:59Z")

</div>

> @Lebsack &nbsp;wrote:&nbsp;[atlas student portal](https://www.atlasfusd.com/)
> 
> A string of the hex digits that proves that the user knows a password. The algorithm encodes the username and password, realm, cnonce, qop, nc, and so on. It is described in detail in the specification.

May it helpful to us ..
