An example implementation of HTTP basic authentication.
| 558 | |
| 559 | |
| 560 | class HttpBasicClientAuthHandler(ClientAuthHandler): |
| 561 | """An example implementation of HTTP basic authentication.""" |
| 562 | |
| 563 | def __init__(self, username, password): |
| 564 | super().__init__() |
| 565 | self.basic_auth = flight.BasicAuth(username, password) |
| 566 | self.token = None |
| 567 | |
| 568 | def authenticate(self, outgoing, incoming): |
| 569 | auth = self.basic_auth.serialize() |
| 570 | outgoing.write(auth) |
| 571 | self.token = incoming.read() |
| 572 | |
| 573 | def get_token(self): |
| 574 | return self.token |
| 575 | |
| 576 | |
| 577 | class TokenServerAuthHandler(ServerAuthHandler): |
no outgoing calls