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