blob: df096a717b51324b0a296acd0685b562d4641fa6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
from .auth_pb2 import CredentialsResponse
from .auth_grpc import AuthBase
from ..grpc import Attachable
from docker.auth import resolve_authconfig
class Auth(AuthBase, Attachable):
def __init__(self, authconfig, credstore_env, *args, **kwargs):
self.authconfig = authconfig
self.credstore_env = credstore_env
super(Auth, self).__init__(*args, **kwargs)
async def Credentials(self, stream):
request = await stream.recv_message()
host = request.Host
auth_data = resolve_authconfig(
self.authconfig, host, self.credstore_env
)
response = None
if auth_data is None:
response = CredentialsResponse(Username=None, Secret=None)
else:
response = CredentialsResponse(
Username=auth_data['Username'], Secret=auth_data['Password']
)
await stream.send_message(response)
|