Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Removing token revoke / delete calls
Browse files Browse the repository at this point in the history
Keysonte is changing the nature of tokens, timeouts, and long
running tasks.  In addition, horizon can also cause issues where
a user starts a long running tasks, logs out, and then the token
fails authenticaion.   Just removing this problematic logic.

https://blueprints.launchpad.net/keystone/+spec/session-extendable-tokens

Closes-Bug: #1637460
Change-Id: I5eda08e95d8df72ba601181f02a72de37c5393fd
  • Loading branch information
eric authored and Eric Peterson committed Oct 28, 2016
1 parent 24de1fb commit 5810f9c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 49 deletions.
15 changes: 0 additions & 15 deletions openstack_auth/tests/tests.py
Expand Up @@ -130,20 +130,6 @@ def _mock_unscoped_client_list_tenants(self, user, tenants):
client = self._mock_unscoped_client(user)
self._mock_unscoped_list_tenants(client, tenants)

def _mock_client_delete_token(self, user, token, url=None):
if not url:
url = settings.OPENSTACK_KEYSTONE_URL

plugin = token_endpoint.Token(
endpoint=url,
token=self.data.unscoped_access_info.auth_token)

client = self.ks_client_module.Client(session=mox.IsA(session.Session),
auth=plugin)
client.tokens = self.mox.CreateMockAnything()
client.tokens.delete(token=token)
return client

def _create_password_auth(self, username=None, password=None, url=None):
if not username:
username = self.data.user.name
Expand Down Expand Up @@ -340,7 +326,6 @@ def test_switch(self, next=None):

self._mock_unscoped_client_list_tenants(user, tenants)
self._mock_scoped_client_for_tenant(unscoped, self.data.tenant_one.id)
self._mock_client_delete_token(user, unscoped.auth_token, endpoint)
self._mock_scoped_client_for_tenant(scoped, tenant.id, url=endpoint,
client=False)

Expand Down
1 change: 1 addition & 0 deletions openstack_auth/utils.py
Expand Up @@ -144,6 +144,7 @@ def get_keystone_client():


def is_token_deletion_disabled():
LOG.warning("Deprecated TOKEN_DELETION_DISABLED setting is no longer used")
return getattr(settings, 'TOKEN_DELETION_DISABLED', False)


Expand Down
35 changes: 1 addition & 34 deletions openstack_auth/views.py
Expand Up @@ -27,7 +27,6 @@
from django.views.decorators.csrf import csrf_protect # noqa
from django.views.decorators.debug import sensitive_post_parameters # noqa
from keystoneauth1 import exceptions as keystone_exceptions
from keystoneauth1 import token_endpoint
import six

from openstack_auth import exceptions
Expand Down Expand Up @@ -159,17 +158,6 @@ def logout(request, login_url=None, **kwargs):
msg = 'Logging out user "%(username)s".' % \
{'username': request.user.username}
LOG.info(msg)
endpoint = request.session.get('region_endpoint')

# delete the project scoped token
token = request.session.get('token')
if token and endpoint:
delete_token(endpoint=endpoint, token_id=token.id)

# delete the domain scoped token if set
domain_token = request.session.get('domain_token')
if domain_token and endpoint:
delete_token(endpoint=endpoint, token_id=domain_token.auth_token)

""" Securely logs a user out. """
return django_auth_views.logout_then_login(request, login_url=login_url,
Expand All @@ -178,24 +166,7 @@ def logout(request, login_url=None, **kwargs):

def delete_token(endpoint, token_id):
"""Delete a token."""
if utils.is_token_deletion_disabled():
return
try:
endpoint, __ = utils.fix_auth_url_version_prefix(endpoint)

session = utils.get_session()
auth_plugin = token_endpoint.Token(endpoint=endpoint,
token=token_id)
client = utils.get_keystone_client().Client(session=session,
auth=auth_plugin)
if utils.get_keystone_version() >= 3:
client.tokens.revoke_token(token=token_id)
else:
client.tokens.delete(token=token_id)

LOG.info('Deleted token %s' % token_id)
except keystone_exceptions.ClientException:
LOG.info('Could not delete token')
LOG.warn("The delete_token method is deprecated and now does nothing")


@login_required
Expand Down Expand Up @@ -234,10 +205,6 @@ def switch(request, tenant_id, redirect_field_name=auth.REDIRECT_FIELD_NAME):
redirect_to = settings.LOGIN_REDIRECT_URL

if auth_ref:
old_endpoint = request.session.get('region_endpoint')
old_token = request.session.get('token')
if old_token and old_endpoint and old_token.id != auth_ref.auth_token:
delete_token(endpoint=old_endpoint, token_id=old_token.id)
user = auth_user.create_user_from_token(
request,
auth_user.Token(auth_ref, unscoped_token=unscoped_token),
Expand Down

0 comments on commit 5810f9c

Please sign in to comment.