mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 21:37:42 -02:30
Merge pull request #6689 from john-westcott-iv/collections_oauth_respect
Make the module util respect oauth token over username/password Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -307,9 +307,9 @@ class TowerModule(AnsibleModule):
|
|||||||
# Extract the headers, this will be used in a couple of places
|
# Extract the headers, this will be used in a couple of places
|
||||||
headers = kwargs.get('headers', {})
|
headers = kwargs.get('headers', {})
|
||||||
|
|
||||||
# Authenticate to Tower (if we've not already done so)
|
# Authenticate to Tower (if we don't have a token and if not already done so)
|
||||||
if not self.authenticated:
|
if not self.oauth_token and not self.authenticated:
|
||||||
# This method will set a cookie in the cookie jar for us
|
# This method will set a cookie in the cookie jar for us and also an oauth_token
|
||||||
self.authenticate(**kwargs)
|
self.authenticate(**kwargs)
|
||||||
if self.oauth_token:
|
if self.oauth_token:
|
||||||
# If we have a oauth token, we just use a bearer header
|
# If we have a oauth token, we just use a bearer header
|
||||||
@@ -683,7 +683,7 @@ class TowerModule(AnsibleModule):
|
|||||||
return self.create_if_needed(existing_item, new_item, endpoint, on_create=on_create, item_type=item_type, associations=associations)
|
return self.create_if_needed(existing_item, new_item, endpoint, on_create=on_create, item_type=item_type, associations=associations)
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
if self.oauth_token_id is not None and self.username and self.password:
|
if self.authenticated:
|
||||||
# Attempt to delete our current token from /api/v2/tokens/
|
# Attempt to delete our current token from /api/v2/tokens/
|
||||||
# Post to the tokens endpoint with baisc auth to try and get a token
|
# Post to the tokens endpoint with baisc auth to try and get a token
|
||||||
api_token_url = (
|
api_token_url = (
|
||||||
|
|||||||
Reference in New Issue
Block a user