Skip to content

Commit

Permalink
Add a new helper function to retrieve an eauth token from the new /token
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteinge committed Dec 14, 2017
1 parent ea0dde8 commit 5508c6c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pepper/libpepper.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -438,17 +438,24 @@ def wheel(self, fun, arg=None, kwarg=None, **kwargs):


return self.low([low]) return self.low([low])


def login(self, username, password, eauth): def _send_auth(self, path, **kwargs):
return self.req(path, kwargs)

def login(self, **kwargs):
''' '''
Authenticate with salt-api and return the user permissions and Authenticate with salt-api and return the user permissions and
authentication token or an empty dict authentication token or an empty dict
''' '''
self.auth = self.req('/login', { self.auth = self._send_auth('/login', **kwargs).get('return', [{}])[0]
'username': username, return self.auth
'password': password,
'eauth': eauth}).get('return', [{}])[0]


def token(self, **kwargs):
'''
Get an eauth token from Salt for use with the /run URL
'''
self.auth = self._send_auth('/token', **kwargs)[0]
return self.auth return self.auth


def _construct_url(self, path): def _construct_url(self, path):
Expand Down

0 comments on commit 5508c6c

Please sign in to comment.