Skip to content

Commit f87815f

Browse files
committed
Revert "improve /run handling, token handling with /run"
This reverts commit 59c013a. this fixes tornado but breaks cherrypy - I mistakenly assumed the payload token returned on login was the real eauth token not the session.id. I'll add a route to /token in tornado that is equivalent to /login on tornado to mimick backcompat behavior even though they are equivalent there due to not having a proxy session store.
1 parent cab58b2 commit f87815f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

pepper/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ def poll_for_returns(self, api, load):
603603
yield exit_code, {'Failed': failed}
604604

605605
def login(self, api):
606+
login = api.token if self.options.userun else api.login
607+
606608
if self.options.mktoken:
607609
token_file = self.options.cache
608610
try:
@@ -616,7 +618,7 @@ def login(self, api):
616618
logger.error('Unable to load login token from {0} {1}'.format(token_file, str(e)))
617619
if os.path.isfile(token_file):
618620
os.remove(token_file)
619-
auth = api.login(**self.parse_login())
621+
auth = login(**self.parse_login())
620622
try:
621623
oldumask = os.umask(0)
622624
fdsc = os.open(token_file, os.O_WRONLY | os.O_CREAT, 0o600)
@@ -627,7 +629,7 @@ def login(self, api):
627629
finally:
628630
os.umask(oldumask)
629631
else:
630-
auth = api.login(**self.parse_login())
632+
auth = login(**self.parse_login())
631633

632634
api.auth = auth
633635
self.auth = auth

pepper/libpepper.py

Lines changed: 9 additions & 1 deletion
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 path != '/run' and self.auth and 'token' in self.auth and self.auth['token']:
222+
if 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,6 +467,14 @@ 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+
470478
def _construct_url(self, path):
471479
'''
472480
Construct the url to salt-api for the given path

0 commit comments

Comments
 (0)