yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #82120
[Bug 1869708] Re: monasca ui throws an ''AnonymousUser' object has no attribute 'project_id'" error when not logged in
Reviewed: https://review.opendev.org/712794
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=e4fd69292c4a8340eba33f5c9d516796472e9269
Submitter: Zuul
Branch: master
commit e4fd69292c4a8340eba33f5c9d516796472e9269
Author: Jacek Tomasiak <jacek.tomasiak@xxxxxxxxx>
Date: Thu Mar 12 21:50:49 2020 +0100
Authenticate before Authorization
When user is not logged in and given Dashboard has some `permissions`
defined, `require_perms` decorator was raising `NotAuthorized('You are
not authorized to access %s')` instead of `NotAuthenticated('Please log
in to continue.')`.
This was caused by the order of decorating the views. The decorator
which is applied last is called first in the chain as it wraps the
decorators which were applied before.
This means that to check for authentication before checking permissions
we need to apply the `require_auth` decorator after `require_perms`.
Closes-Bug: 1869708
Change-Id: I94d3fa5c1472bb72c9111cab14c6e05180f88589
** Changed in: horizon
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1869708
Title:
monasca ui throws an ''AnonymousUser' object has no attribute
'project_id'" error when not logged in
Status in OpenStack Dashboard (Horizon):
Fix Released
Bug description:
# Copy from internal bug tracker
When accessing the monitoring url while not logged in (or while waited a day and trying to access the site again (logged out meanwhile)) in the OpenStack dashboard, the site throws an error:
[Fri Feb 01 11:01:57.218156 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] Internal Server Error: /monitoring/
[Fri Feb 01 11:01:57.218229 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] Traceback (most recent call last):
[Fri Feb 01 11:01:57.218239 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
[Fri Feb 01 11:01:57.218257 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] response = get_response(request)
[Fri Feb 01 11:01:57.218265 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Fri Feb 01 11:01:57.218273 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] response = self.process_exception_by_middleware(e, request)
[Fri Feb 01 11:01:57.218281 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 227, in process_exception_by_middleware
[Fri Feb 01 11:01:57.218290 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] response = middleware_method(request, exception)
[Fri Feb 01 11:01:57.218306 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/horizon/middleware/base.py", line 131, in process_exception
[Fri Feb 01 11:01:57.218314 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] status=403)
[Fri Feb 01 11:01:57.218322 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/shortcuts.py", line 30, in render
[Fri Feb 01 11:01:57.218329 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] content = loader.render_to_string(template_name, context, request, using=using)
[Fri Feb 01 11:01:57.218345 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/loader.py", line 68, in render_to_string
[Fri Feb 01 11:01:57.218352 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return template.render(context, request)
[Fri Feb 01 11:01:57.218370 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
[Fri Feb 01 11:01:57.218378 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.template.render(context)
[Fri Feb 01 11:01:57.218385 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 207, in render
[Fri Feb 01 11:01:57.218392 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self._render(context)
[Fri Feb 01 11:01:57.218400 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
[Fri Feb 01 11:01:57.218407 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.nodelist.render(context)
[Fri Feb 01 11:01:57.218414 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
[Fri Feb 01 11:01:57.218422 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] bit = node.render_annotated(context)
[Fri Feb 01 11:01:57.218429 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
[Fri Feb 01 11:01:57.218436 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.render(context)
[Fri Feb 01 11:01:57.218444 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
[Fri Feb 01 11:01:57.218451 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return compiled_parent._render(context)
[Fri Feb 01 11:01:57.218458 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
[Fri Feb 01 11:01:57.218466 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.nodelist.render(context)
[Fri Feb 01 11:01:57.218473 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
[Fri Feb 01 11:01:57.218481 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] bit = node.render_annotated(context)
[Fri Feb 01 11:01:57.218488 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
[Fri Feb 01 11:01:57.218505 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.render(context)
[Fri Feb 01 11:01:57.218511 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 72, in render
[Fri Feb 01 11:01:57.218519 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] result = block.nodelist.render(context)
[Fri Feb 01 11:01:57.218526 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
[Fri Feb 01 11:01:57.218533 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] bit = node.render_annotated(context)
[Fri Feb 01 11:01:57.218541 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
[Fri Feb 01 11:01:57.218553 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.render(context)
[Fri Feb 01 11:01:57.218566 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 216, in render
[Fri Feb 01 11:01:57.218585 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return template.render(context)
[Fri Feb 01 11:01:57.218593 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 209, in render
[Fri Feb 01 11:01:57.218600 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self._render(context)
[Fri Feb 01 11:01:57.218608 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
[Fri Feb 01 11:01:57.218615 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.nodelist.render(context)
[Fri Feb 01 11:01:57.218622 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
[Fri Feb 01 11:01:57.218629 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] bit = node.render_annotated(context)
[Fri Feb 01 11:01:57.218636 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
[Fri Feb 01 11:01:57.218643 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.render(context)
[Fri Feb 01 11:01:57.218650 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/defaulttags.py", line 411, in render
[Fri Feb 01 11:01:57.218657 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return strip_spaces_between_tags(self.nodelist.render(context).strip())
[Fri Feb 01 11:01:57.218664 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
[Fri Feb 01 11:01:57.218671 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] bit = node.render_annotated(context)
[Fri Feb 01 11:01:57.218678 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
[Fri Feb 01 11:01:57.218685 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.render(context)
[Fri Feb 01 11:01:57.218693 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 216, in render
[Fri Feb 01 11:01:57.218700 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return template.render(context)
[Fri Feb 01 11:01:57.218706 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 209, in render
[Fri Feb 01 11:01:57.218714 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self._render(context)
[Fri Feb 01 11:01:57.218721 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
[Fri Feb 01 11:01:57.218728 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.nodelist.render(context)
[Fri Feb 01 11:01:57.218735 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
[Fri Feb 01 11:01:57.218742 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] bit = node.render_annotated(context)
[Fri Feb 01 11:01:57.218748 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
[Fri Feb 01 11:01:57.218756 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return self.render(context)
[Fri Feb 01 11:01:57.218763 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/template/library.py", line 225, in render
[Fri Feb 01 11:01:57.218772 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] _dict = self.func(*resolved_args, **resolved_kwargs)
[Fri Feb 01 11:01:57.218780 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/srv/www/openstack-dashboard/openstack_dashboard/templatetags/context_selection.py", line 55, in show_overview
[Fri Feb 01 11:01:57.218787 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] project_name = get_project_name(request.user.project_id,
[Fri Feb 01 11:01:57.218794 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 239, in inner
[Fri Feb 01 11:01:57.218802 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] return func(self._wrapped, *args)
[Fri Feb 01 11:01:57.218808 2019] [wsgi:error] [pid 32737] [remote 10.163.0.83:60796] AttributeError: 'AnonymousUser' object has no attribute 'project_id'
To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1869708/+subscriptions
References