# get\_url and preemptive authentication?

**URL:** <https://forum.ansible.com/t/get-url-and-preemptive-authentication/16856>\
**Category:** Ansible Project\
**Created:** [November 23, 2014, 11:14am UTC](https://forum.ansible.com/t/get-url-and-preemptive-authentication/16856 "2014-11-23T11:14:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mirko\_Friedenhagen](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mirko\_Friedenhagen](https://forum.ansible.com/u/Mirko_Friedenhagen)\
**Post date:** [November 23, 2014, 11:14am UTC](https://forum.ansible.com/t/get-url-and-preemptive-authentication/16856/1 "2014-11-23T11:14:53Z")

</div>

Hello,

we provide user specific settings for our Maven repository via a HTTP  
GET request[1], but have the usecase that "anonymous" has read-only  
access, so authentication is not strictly enforced.

I try to setup our CI system with ansible coming from a shell based  
setup, where I have:

curl --netrc -o ~/.m2/settings.xml [http://repo/path/settings.xml](http://repo/path/settings.xml)

Now, curl sends the basic auth header in any case, while get\_url[2]  
waits for a 401 to come back before offering credentials. So with  
get\_url the credentials are not used but the settings.xml for  
anonymous are downloaded.

I could implement a PR with an option to send authentication  
preemptively and default to the current behavior.

On the other hand I think anyone using get\_url with url\_password knows  
that authentication is needed, so IMO sending the auth-header directly  
by default would be more useful and the current behavior only produces  
the overhead of additional requests.

Regards Mirko  
[1] we use Artifactory templating here.  
[2] inspecting ansible/module\_utils/urls.py

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 24, 2014, 1:30pm UTC](https://forum.ansible.com/t/get-url-and-preemptive-authentication/16856/2 "2014-11-24T13:30:37Z")

</div>

You might be interested in [https://github.com/ansible/ansible-modules-core/pull/153](https://github.com/ansible/ansible-modules-core/pull/153)

---

<div class="post-metadata">

**Author:** ![Mirko\_Friedenhagen](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mirko\_Friedenhagen](https://forum.ansible.com/u/Mirko_Friedenhagen)\
**Post date:** [November 24, 2014, 9:21pm UTC](https://forum.ansible.com/t/get-url-and-preemptive-authentication/16856/3 "2014-11-24T21:21:26Z")

</div>

Hello Matt,

thanks, any chances that this will make it into version 1.8?  
Regards Mirko

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 24, 2014, 10:28pm UTC](https://forum.ansible.com/t/get-url-and-preemptive-authentication/16856/4 "2014-11-24T22:28:39Z")

</div>

1.8 is releasing soon so this is unlikely.

It is prioritized p3 so it’s next in line though.

You can use your own version of get\_url by dropping in “./library” relative to your playbook, which would allow you to use this today.

---

<div class="post-metadata">

**Author:** ![Mirko\_Friedenhagen](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mirko\_Friedenhagen](https://forum.ansible.com/u/Mirko_Friedenhagen)\
**Post date:** [November 25, 2014, 8:33am UTC](https://forum.ansible.com/t/get-url-and-preemptive-authentication/16856/5 "2014-11-25T08:33:39Z")

</div>

Thanks, good to know 🙂

Regards  
Mirko
