Hack Forums
[Python] Urllib2 module what is a "realm" - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Urllib2 module what is a "realm" (/showthread.php?tid=5986775)



Urllib2 module what is a "realm" - Oracle - Jul 5, 2019

I am spending a couple of days to understand what a realm is? and how can i know which authentication i use in each website
( Basic / Digest ) before i start coding i want to know what is that? how does it work? and during your answers i might have more question (if it will be clear, then i won't)

Thanks to the "knowers"


RE: Urllib2 module what is a "realm" - l0lwtf - Jul 5, 2019

I would not recommend using urllib, instead, use Python Requests. This module will make your life easier.

A realm can be thought of as an environment where multiple (or one) URL(s) are protected by a password. When your browser makes a HTTP request, asking the server for some HTML, the server may respond with "you need a password for this realm" or more simply "you need a password to receive this HTML".

In addition, the same server HTTP response will also contain what kind of authentication scheme to use. There is one called Basic, there is one called Digest. Whatever the server tells you to use, you should use.

What I have described above is communicated via HTTP response headers. You should look up how a HTTP request and how a HTTP response looks like when it goes over the wire. This will help you in understanding how to communicate with a webserver.

As for the difference between the 2 authentication schemes: Basic auth is a password, unencrypted with base64 encoding while Digest does some encryption stuff involving a nonce.

Python requests can deal with both (and urllib for that matter).


RE: Urllib2 module what is a "realm" - Oracle - Jul 6, 2019

(Jul 5, 2019 05:19 PM)l0lwtf Wrote:  I would not recommend using urllib, instead, use Python Requests. This module will make your life easier.

A realm can be thought of as an environment where multiple (or one) URL(s) are protected by a password. When your browser makes a HTTP request, asking the server for some HTML, the server may respond with "you need a password for this realm" or more simply "you need a password to receive this HTML".

In addition, the same server HTTP response will also contain what kind of authentication scheme to use. There is one called Basic, there is one called Digest. Whatever the server tells you to use, you should use.

What I have described above is communicated via HTTP response headers. You should look up how a HTTP request and how a HTTP response looks like when it goes over the wire. This will help you in understanding how to communicate with a webserver.

As for the difference between the 2 authentication schemes: Basic auth is a password, unencrypted with base64 encoding while Digest does some encryption stuff involving a nonce.

Python requests can deal with both (and urllib for that matter).



Thank you so much for your reply... i am using now urllib2 only to understand how it works before i start coding my question is can i see the  the realm and what kind of authentication i should use in the response come back from the server? (Like headers / what kind of server response to me.... in command like
Res = urlopen(abcd)
Res.headers
Res.info
...