Skip to content

Commit

Permalink
Fix token authentication bugs (#27)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Finucane <[email protected]>
  • Loading branch information
rossburton and stephenfin authored Nov 17, 2023
1 parent 88adfe2 commit 6120b39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions pwclient/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,8 @@ def _generate_headers(self, additional_headers=None):
}

if self._token:
pass

if self._username:
headers['Authorization'] = f"Token {self._token}"
elif self._username and self._password:
credentials = base64.b64encode(
f'{self._username}:{self._password}'.encode('ascii')
).decode('ascii')
Expand Down
9 changes: 6 additions & 3 deletions pwclient/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ def main(argv=sys.argv[1:]):
if action in auth_actions:
if backend == 'rest':
if not (
config.has_option(project_str, 'username')
and config.has_option(project_str, 'password')
) or config.has_option(project_str, 'token'):
(
config.has_option(project_str, 'username')
and config.has_option(project_str, 'password')
)
or config.has_option(project_str, 'token')
):
sys.stderr.write(
"The %s action requires authentication, but no "
"username/password or\n"
Expand Down

0 comments on commit 6120b39

Please sign in to comment.