Skip to content

Commit 59c013a

Browse files
committed
improve /run handling, token handling with /run
make this act more reasonable. we drop the x-auth-token header when using /run as the idea of that endpoint is to use whats in the lowstate. we get rid of the /token route handling as it seemingly does the same thing as /login, and doesnt actually exist in the rest_tornado impl so I'm considering it deprecated for simplicity.
1 parent 02acbc1 commit 59c013a

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

pepper/cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,6 @@ def poll_for_returns(self, api, load):
598598
list(set(ret_nodes) ^ set(nodes)))
599599

600600
def login(self, api):
601-
login = api.token if self.options.userun else api.login
602-
603601
if self.options.mktoken:
604602
token_file = self.options.cache
605603
try:
@@ -613,7 +611,7 @@ def login(self, api):
613611
logger.error('Unable to load login token from {0} {1}'.format(token_file, str(e)))
614612
if os.path.isfile(token_file):
615613
os.remove(token_file)
616-
auth = login(**self.parse_login())
614+
auth = api.login(**self.parse_login())
617615
try:
618616
oldumask = os.umask(0)
619617
fdsc = os.open(token_file, os.O_WRONLY | os.O_CREAT, 0o600)
@@ -624,7 +622,7 @@ def login(self, api):
624622
finally:
625623
os.umask(oldumask)
626624
else:
627-
auth = login(**self.parse_login())
625+
auth = api.login(**self.parse_login())
628626

629627
api.auth = auth
630628
self.auth = auth

pepper/libpepper.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def req(self, path, data=None):
219219
req.add_header('Content-Length', clen)
220220

221221
# Add auth header to request
222-
if self.auth and 'token' in self.auth and self.auth['token']:
222+
if path != '/run' and self.auth and 'token' in self.auth and self.auth['token']:
223223
req.add_header('X-Auth-Token', self.auth['token'])
224224

225225
# Send request
@@ -467,14 +467,6 @@ def login(self, username=None, password=None, eauth=None, **kwargs):
467467
self.auth = self._send_auth('/login', **kwargs).get('return', [{}])[0]
468468
return self.auth
469469

470-
def token(self, **kwargs):
471-
'''
472-
Get an eauth token from Salt for use with the /run URL
473-
474-
'''
475-
self.auth = self._send_auth('/token', **kwargs)[0]
476-
return self.auth
477-
478470
def _construct_url(self, path):
479471
'''
480472
Construct the url to salt-api for the given path

0 commit comments

Comments
 (0)