An example implementation of authentication via handshake.
| 596 | |
| 597 | |
| 598 | class TokenClientAuthHandler(ClientAuthHandler): |
| 599 | """An example implementation of authentication via handshake.""" |
| 600 | |
| 601 | def __init__(self, username, password): |
| 602 | super().__init__() |
| 603 | self.username = username |
| 604 | self.password = password |
| 605 | self.token = b'' |
| 606 | |
| 607 | def authenticate(self, outgoing, incoming): |
| 608 | outgoing.write(self.username) |
| 609 | outgoing.write(self.password) |
| 610 | self.token = incoming.read() |
| 611 | |
| 612 | def get_token(self): |
| 613 | return self.token |
| 614 | |
| 615 | |
| 616 | class NoopAuthHandler(ServerAuthHandler): |
no outgoing calls