Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Urllib2 module what is a "realm"

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"
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).
(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
...


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by CleverUSBDec 29, 2017 11:31 AM 5 320 Dec 29, 2017 11:31 AM
Last Post: CleverUSB
[Python] by KomodoApr 18, 2017 03:04 PM 13 373 Apr 18, 2017 03:04 PM
Last Post: captainspalding
[Python] by SkidyApr 13, 2017 03:16 AM 2 138 Apr 13, 2017 03:16 AM
Last Post: Skidy