mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Update auth data on reauth.
If minion reauth in a subprocess, like scheduler jobs, update the auth data in the main process by sending and handling a local event.
This commit is contained in:
parent
0f0f15d048
commit
778ae9a9ff
@ -469,10 +469,14 @@ class AsyncAuth(object):
|
||||
error = SaltClientError('Attempt to authenticate with the salt master failed')
|
||||
self._authenticate_future.set_exception(error)
|
||||
else:
|
||||
AsyncAuth.creds_map[self.__key(self.opts)] = creds
|
||||
key = self.__key(self.opts)
|
||||
AsyncAuth.creds_map[key] = creds
|
||||
self._creds = creds
|
||||
self._crypticle = Crypticle(self.opts, creds['aes'])
|
||||
self._authenticate_future.set_result(True) # mark the sign-in as complete
|
||||
# Notify the bus about creds change
|
||||
event = salt.utils.event.get_event(self.opts.get('__role'), opts=self.opts, listen=False)
|
||||
event.fire_event({'key': key, 'creds': creds}, salt.utils.event.tagify(prefix='auth', suffix='creds'))
|
||||
|
||||
@tornado.gen.coroutine
|
||||
def sign_in(self, timeout=60, safe=True, tries=1, channel=None):
|
||||
|
@ -1659,6 +1659,12 @@ class Minion(MinionBase):
|
||||
tag, data = salt.utils.event.MinionEvent.unpack(package)
|
||||
log.debug('Forwarding salt error event tag={tag}'.format(tag=tag))
|
||||
self._fire_master(data, tag)
|
||||
elif package.startswith('salt/auth/creds'):
|
||||
tag, data = salt.utils.event.MinionEvent.unpack(package)
|
||||
key = tuple(data['key'])
|
||||
log.debug('Updating auth data for {0}: {1} -> {2}'.format(
|
||||
key, salt.crypt.AsyncAuth.creds_map.get(key), data['creds']))
|
||||
salt.crypt.AsyncAuth.creds_map[tuple(data['key'])] = data['creds']
|
||||
|
||||
def _fallback_cleanups(self):
|
||||
'''
|
||||
|
@ -581,7 +581,7 @@ class SaltEvent(object):
|
||||
self.opts['max_event_size'],
|
||||
is_msgpacked=True,
|
||||
)
|
||||
log.debug('Sending event - data = {0}'.format(data))
|
||||
log.debug('Sending event: tag = {0}; data = {1}'.format(tag, data))
|
||||
event = '{0}{1}{2}'.format(tag, tagend, serialized_data)
|
||||
try:
|
||||
self.push.send(salt.utils.to_bytes(event, 'utf-8'))
|
||||
|
Loading…
Reference in New Issue
Block a user