Skip to content

Commit

Permalink
clean up old authtoken support
Browse files Browse the repository at this point in the history
always Bearer tokens - those are the only type of tokens we support
  • Loading branch information
ryanpetrello committed Aug 19, 2020
1 parent fb66766 commit 6453fe4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions awxkit/awxkit/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ class ConnectionException(exc.Common):


class Token_Auth(requests.auth.AuthBase):
def __init__(self, token, auth_type='Token'):
def __init__(self, token):
self.token = token
self.auth_type = auth_type

def __call__(self, request):
request.headers['Authorization'] = '{0.auth_type} {0.token}'.format(self)
request.headers['Authorization'] = 'Bearer {0.token}'.format(self)
return request


Expand Down Expand Up @@ -57,7 +56,7 @@ def login(self, username=None, password=None, token=None, **kwargs):
else:
self.session.auth = (username, password)
elif token:
self.session.auth = Token_Auth(token, auth_type=kwargs.get('auth_type', 'Token'))
self.session.auth = Token_Auth(token)
else:
self.session.auth = None

Expand Down
2 changes: 1 addition & 1 deletion awxkit/awxkit/awx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def as_user(v, username, password=None):
if session_id:
del connection.session.cookies['sessionid']
if access_token:
kwargs = dict(token=access_token, auth_type='Bearer')
kwargs = dict(token=access_token)
else:
kwargs = connection.get_session_requirements()
else:
Expand Down
2 changes: 1 addition & 1 deletion awxkit/awxkit/cli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def authenticate(self):
token = self.get_config('token')
if token:
self.root.connection.login(
None, None, token=token, auth_type='Bearer'
None, None, token=token,
)
else:
config.use_sessions = True
Expand Down

0 comments on commit 6453fe4

Please sign in to comment.