| 877 | |
| 878 | |
| 879 | class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm): |
| 880 | |
| 881 | def __init__(self): |
| 882 | self.authenticated = {} |
| 883 | super().__init__() |
| 884 | |
| 885 | def add_password(self, realm, uri, user, passwd, is_authenticated=False): |
| 886 | self.update_authenticated(uri, is_authenticated) |
| 887 | # Add a default for prior auth requests |
| 888 | if realm is not None: |
| 889 | super().add_password(None, uri, user, passwd) |
| 890 | super().add_password(realm, uri, user, passwd) |
| 891 | |
| 892 | def update_authenticated(self, uri, is_authenticated=False): |
| 893 | # uri could be a single URI or a sequence |
| 894 | if isinstance(uri, str): |
| 895 | uri = [uri] |
| 896 | |
| 897 | for default_port in True, False: |
| 898 | for u in uri: |
| 899 | reduced_uri = self.reduce_uri(u, default_port) |
| 900 | self.authenticated[reduced_uri] = is_authenticated |
| 901 | |
| 902 | def is_authenticated(self, authuri): |
| 903 | for default_port in True, False: |
| 904 | reduced_authuri = self.reduce_uri(authuri, default_port) |
| 905 | for uri in self.authenticated: |
| 906 | if self.is_suburi(uri, reduced_authuri): |
| 907 | return self.authenticated[uri] |
| 908 | |
| 909 | |
| 910 | class AbstractBasicAuthHandler: |
no outgoing calls
searching dependent graphs…