diff --git a/changelogs/fragments/242-fix-failed-token-deletion.yml b/changelogs/fragments/242-fix-failed-token-deletion.yml new file mode 100644 index 0000000..a0b770d --- /dev/null +++ b/changelogs/fragments/242-fix-failed-token-deletion.yml @@ -0,0 +1,2 @@ +bugfixes: + - openshift_auth - fix issue where openshift_auth module sometimes does not delete the auth token. Based on stale PR (https://github.com/openshift/community.okd/pull/194). \ No newline at end of file diff --git a/plugins/modules/openshift_auth.py b/plugins/modules/openshift_auth.py index 4fdb169..6e213ab 100644 --- a/plugins/modules/openshift_auth.py +++ b/plugins/modules/openshift_auth.py @@ -224,8 +224,10 @@ def get_oauthaccesstoken_objectname_from_token(token_name): """ sha256Prefix = "sha256~" - content = token_name.strip(sha256Prefix) - + if token_name.startswith(sha256Prefix): + content = token_name[len(sha256Prefix):] + else: + content = token_name b64encoded = urlsafe_b64encode(hashlib.sha256(content.encode()).digest()).rstrip( b"=" )