Commit Graph

141 Commits

Author SHA1 Message Date
Rodrigo Barbieri da8e959298 Fix error on changing user password by admin
Previous change I8438bedaf7cead452fc499e484d23690b48894d9
attempted to address bug LP#1728031 by improving upon
patch https://review.opendev.org/854005 but missed the
line that allows the keystone client to properly
authenticate a cloud admin user that IS NOT in the
default domain.

Without this 1-line fix, a cloud admin that is not
in the default domain will face an "incorrect admin
password" error in the UI (despite the admin password
being correct) and an authentication error in the logs,
regardless of the endpoint type used (adminURL,
internalURL or publicURL).

Closes-bug: #1728031
Change-Id: I018e7d9cb84fd6ce8635c9054e15052ded7e9368
2024-03-14 15:58:43 -03:00
Takashi Kajinami 9fa98969e7 Use OPENSTACK_ENDPOINT_TYPE by default
This is follow-up of I8438bedaf7cead452fc499e484d23690b48894d9 and
ensures the OPENSTACK_ENDPOINT_TYPE parameter is used when
OPENSTACK_KEYSTONE_ENDPOINT_TYPE is not set. This avoids backward-
incompatible change which affects deployments with endpoint type set
to non-default values.

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I94d2d3e31fc0103773fb5d3ed2f5f792e8851f78
2022-12-26 07:01:07 +09:00
Zuul 0add65eddc Merge "Add OPENSTACK_KEYSTONE_ENDPOINT_TYPE config opt" 2022-12-15 17:50:38 +00:00
Rodrigo Barbieri 6eeaf98524 Fix app cred create without project_id for domain admins
Users with domain admin role that are not cloud admins are
not able to get scoped context and create an application
credential with project_id, so this change forces the
scoped context in that particular case.

Closes-bug: #1827120
Change-Id: I076a97a6f943ab74a2db8bc5179a7db194009db4
2022-10-11 07:43:06 +00:00
Tobias Urdin b22a6d65f7 Add OPENSTACK_KEYSTONE_ENDPOINT_TYPE config opt
The [1] changed the previous behavior of Horizon by
changing the hardcoded internal endpoint type to using
OPENSTACK_ENDPOINT_TYPE so it's no longer possible to use
internal endpoint type for Keystone but public for others.

This adds the OPENSTACK_KEYSTONE_ENDPOINT_TYPE config opt
to set the endpoint type for Keystone when grabbing it from
the service catalog.

[1] https://review.opendev.org/c/openstack/horizon/+/730781

Change-Id: I8438bedaf7cead452fc499e484d23690b48894d9
2022-09-29 13:23:59 +00:00
Tobias Urdin e4ac4550c9 Pass real client IP to keystoneauth original_ip
The original_ip parameter for the keystoneauth plugin
sets the Forwarded header sent to Keystone but right now
it just sends the IP address of Horizon instead of the client's
IP when Horizon is proxied and should use X-Forwarded-For.

Change-Id: Ic994b7f36d4c6459bbd00c810e3b454c6b1201a6
2022-04-21 12:19:30 +00:00
Akihiro Motoki 35a490f4ec Do not assume keystone admin endpoint
keystone does not distinguish public and admin endpoints since
Train [1], so there is no need to use a separate endpoint for
keystone admin operations. admin endpoint still can be configured
but there is no functional difference anymore from other endpoints.
We do not need to require admin endpoint and can use an endpoint
specified by OPENSTACK_ENDPOINT_TYPE for all API operations.

This commit reverts commit f9bab3fe19
as we no longer need the workaround.

[1] https://review.opendev.org/c/openstack/keystone/+/664246

Closes-Bug: #1950659
Change-Id: I2660fd2df8081e1d2d9c84626037f94bd9d137a5
2022-03-25 20:06:49 +09:00
Akihiro Motoki cd7c1b5110 Address RemovedInDjango40Warning (2)
django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
ungettext(), and ungettext_lazy() are deprecated in favor of the
functions that they’re aliases for: django.utils.translation.gettext(),
gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy().

https://docs.djangoproject.com/en/4.0/releases/3.0/#id3

Change-Id: I77878f84e9d10cf6a136dada81eabf4e18676250
2022-02-04 16:22:07 +09:00
Mitya_Eremeev 3aaeadf895 Default role checker should be case-insensitive.
Keystone role names are case-insensistive and
Horizon should handle role names in a case-insensitive manner.
For example, when keystone bootstraps default roles,
it creates “admin”, “member”, and “reader”.
If another role, “Member” (note the upper case ‘M’) is created,
keystone will return a 409 Conflict since it considers the name “Member” equivalent to “member”.
Note that case is preserved in this event.
https://docs.openstack.org/keystone/latest/admin/case-insensitive.html#roles
Also whatever is written in defaults can be overridden in settings by the operator -
especially these days when actually the default should be 'member'
(one of the default roles created by Keystone during the bootstrap),
not _member_ which is there for legacy reasons I presume.

Change-Id: Ibfb80a47a8aaed8f33e4e1dcfb428e70c829f0dd
2021-05-21 21:03:09 +03:00
Akihiro Motoki e5d09edc20 Use python3-style super()
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.

pylint provides a check for this.
Let's enable 'super-with-arguments' check.

NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.

Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
2020-10-15 14:37:20 +09:00
Akihiro Motoki 692778f8cf pylint: Address no-else-return warning
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.

Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
2020-09-27 12:44:16 +09:00
Gayathri Devi Kathiri 7bde77fad1 Default keystone endpoint type is hard coded
The default url should be of type "OPENSTACK_ENDPOINT_TYPE"
parameter as specified in settings.

Closes-Bug: #1873353

Change-Id: I05ce933e5bd01bf59a52e7d49facce26efa693aa
2020-06-02 07:47:08 +00:00
Walter Doekes 941f64915e Give keystoneauth1.ClientException only 1 argument (message)
Change-Id: I970b07e52ed7f2f4440b47800fcb3b6528dce22d
2020-04-29 17:25:01 +09:00
Ivan Kolodyazhny ee6fa9a245 Remove Keystone v2 related code
Kyestone V2 support was removed in Train, so it's safe to do such cleanup.

* Functions which just return horizon settings are dropped and
  the settings are referred directly now.
* The service catalog in the sample test data is updated to match
  the format of the keystone API v3.
* Related to the above change of the sample service catalog,
  openstack_dashboard.test.unit.api.test_keystone.ServiceAPITests is
  updated to specify the region name explicitly because 'RegionTwo'
  endpoint is no longer the second entry of the endpoint list in the
  keystone API v3.

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: Ib60f360c96341fa5c618595f4a9bfdfe7ec5ae83
2020-04-23 11:43:12 +09:00
Ivan Kolodyazhny d870b40583 Remove six usage from openstack_dashboard package
We don't support Python 2 anymore so we don't need this
compatibility library.

six.reraise usages are left as is until it'll be moved to some
base lib like oslo.utils to not re-implenent this method in
Horizon.

This patch also removes Python2-specific base test case methods
assertItemsEqual and assertNotRegexpMatches in flavor of new
Python 3 analogues.

Change-Id: I26a59176be9e9f213128e4945a58b9459334b626
2020-01-15 12:47:48 +02:00
Hemanth Nakkina 9aca7a94e2 Fix users/projects list when domain context is changed
In case of Keystone Multidomain setup, the project and users list
is empty when the domain context is changed. Horizon uses domain
scoped token for keystone api calls to get list of projects and users.
And domain scoped token cannot get information about projects and users
in other domains, the list is empty.

This patch modifies the use of domain scoped token only when domain
context is not modified.

The bug have 3 parts
1. Users are not listed on GUI in different domain
2. Projects are not listed on GUI in different domain
3. Gui hangs during creation of user/project using + option
This patch handles case 1 and 2.

Change-Id: Ibafe3e2eb3ee1ee5c9eb5d2a276a0edfa3e7c607
Partial-Bug: #1826114
Closes-Bug: #1830782
2019-12-13 10:06:02 +05:30
Colleen Murphy 4d1786c687 Add support for keystone access rules
Keystone implemented the ability to apply fine-grained access control
restrictions to application credentials[1]. This patch adds new fields
to the application credential creation form and detail view so that
horizon users can use this feature.

[1] http://specs.openstack.org/openstack/keystone-specs/specs/keystone/train/capabilities-app-creds.html

Depends-on: https://review.opendev.org/677585

Change-Id: I2d71392eb8569ffb8cb15af29eea76e120a158cc
2019-10-30 14:47:05 +09:00
Akihiro Motoki ec970fd6e8 Handle partial dict setting
In Train cycle, we moved the definition of default values
to openstack_dashboard/defaults.py. The current code accesses
a dict member using []. It requires operators to define a dict
setting with a full member.

This commit allows to use dict-type settings with partial members.

A new function is introduced to retrieve a dict-type setting
considering default values defined in
{openstack_dashboard,horizon,openstack_auth}/defaults.py

Change-Id: I7ff0ad4bca698aef9c0eba370b0570200a14367a
Closes-Bug: #1843104
2019-09-26 14:31:17 +09:00
Ivan Kolodyazhny f33e5fd8ac Drop deprecated Keystone V2 API support
Keystone V2 API was deprecated in Stein release in Horizon and
removed from Keystone in Queens release.

Change-Id: I917e273d3174adf0874e516b3d635ccb8ba58a27
2019-09-12 17:15:07 +00:00
Akihiro Motoki 7c897b677c Move openstack_dashboard specific settings from horizon
Cookie-based settings related to openstack_dashboard are located
under horizon directory,, but they are not related to "horizon".
This commit moves them to "openstack_dashboard" directory.

Part of blueprint ini-based-configuration
Change-Id: Id48ececdbe819a95485e9a91dc5a1a163a5568c3
2019-09-12 15:05:56 +09:00
Andy Botting c238b519f3 Revert "Raise NotFound error when retrieved by not uuid"
In the early days of OpenStack, user and project ids were not
uuids, but auto-incremented integers.

Since those early days, many operators fought long battles
against the unrelenting OpenStack behemoth.

Only those heroic operators who emerged victorious from the
brutal upgrade battles can show the scars of those integer
user and project ids like badges of honour.

Closes-Bug: #1842004
Change-Id: I0c3e3465e8e7499c94d1a82b7295aeec13955e55
2019-08-30 08:59:24 +10:00
Akihiro Motoki 9c19b07a26 Define default settings explicitly (openstack_dashboard 1/5)
Currently horizon defines default values of settings in the logic
using getattr(settings, <setting name>, <default value>) and
it is not easy to handle the default values of available settings.

This commit starts the effort to define default settings explicitly.
This is a preparation for ini-based-configurations.

It covers settings in openstack_dashboard/api.

Part of blueprint ini-based-configuration
Change-Id: Id4c3287f0a572fd14ea93b54bcab8fabda39e583
2019-04-24 02:32:47 +09:00
Zuul 4837656b32 Merge "Make domain_lookup return consistent type" 2019-03-18 18:40:24 +00:00
Zuul 8b4d702a84 Merge "Modify the error messages of Create group and update group" 2019-03-18 17:45:21 +00:00
Radomir Dopieralski 8e13106adb Make domain_lookup return consistent type
It is possible to make Horizon reach the "Pure project admin doesn't
have a domain token" state in domain_lookup by having different policy
files in Keystone and in Horizon, at which point it results in an
unhelpful AttributeError later on, because domain_lookup returns None.

I'm proposing to make it return an empty dict instead, this way Horizon
doesn't crash, but we still get the warning in the logs.

Change-Id: I7a42e8defb2fb348cac8225fb1dcbf5e86c9e65c
2019-03-15 09:15:28 +01:00
pengyuesheng 07e8543e55 Modify the error messages of Create group and update group
When group name is already used,
we should prompt detailed error message

Change-Id: I95ee96d06e3b94e89be4744b2e6f00816e54792a
Closes-Bug: #1816010
2019-02-25 09:20:32 +08:00
pengyuesheng eb6a78f517 Throws exceptions.Conflict() in the interface application_credential_create
Change-Id: I285a588acf30b5e0858f98ff3d847a4049eb6b34
Closes-Bug: #1816684
2019-02-20 14:56:08 +08:00
Akihiro Motoki b06657b07d Fix gate failures by a new pycodestyle
pycodestyle 2.5.0 introduces E117 over-indented.
This commit fixes E117 errors.

pycodestyle 2.5.0 also drops pep8.py. As a result,
horizon/test/unit/hacking/test_checks.py starts to fail.
The equivalent elements are provided by pycodestyle.py,
so we can consume pycodestyle instead of pep8 module.

Change-Id: Ib103998f42ce7c901a10669b771a898783ca1a92
2019-01-30 17:02:20 +09:00
Zuul 60dd57655b Merge "pylint: fix some refactor recommendations" 2019-01-16 17:57:12 +00:00
Akihiro Motoki 7c585e2643 pylint: fix some refactor recommendations
openstack_dashboard/dashboards/project/security_groups/forms.py:393:13: R1714: Consider merging these comparisons with "in" to "rule_menu in ('tcp', 'udp')" (consider-using-in)
openstack_dashboard/api/rest/json_encoder.py:61:15: R0124: Redundant comparison - o != o (comparison-with-itself)
openstack_dashboard/api/keystone.py:904:15: R1714: Consider merging these comparisons with "in" to 'default in (role.id, role.name)' (consider-using-in)
horizon/templatetags/truncate_filter.py:30:7: R1716: Simplify chained comparison between the operands (chained-comparison)

Change-Id: I6cf8602f88c4027ff12aaa4ea5a9f2069ae2e2a6
2019-01-17 00:44:19 +09:00
Akihiro Motoki ac7ac272b3 pylint: fix several coding convention violations
openstack_dashboard/context_processors.py:94:15: C0122: Comparison should be link['url'] != 'horizon:project:api_access:openrcv2' (misplaced-comparison-constant)
openstack_dashboard/settings.py:467:4: C0412: Imports from package horizon are not grouped (ungrouped-imports)
openstack_dashboard/enabled/_1370_project_vg_snapshots.py:9:0: C0301: Line too long (86/80) (line-too-long)
openstack_dashboard/enabled/_1360_project_volume_groups.py:9:0: C0301: Line too long (85/80) (line-too-long)
openstack_dashboard/usage/base.py:62:8: W0106: Expression "[instance_list.extend(u.server_usages) for u in self.usage_list]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:43:12: W0106: Expression "[public_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:75:12: W0106: Expression "[community_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/api/glance.py:47:4: C0412: Imports from package glanceclient are not grouped (ungrouped-imports)
openstack_dashboard/api/cinder.py:60:4: C0412: Imports from package cinderclient are not grouped (ungrouped-imports)
openstack_auth/user.py:358:4: E0211: Method has no argument (no-method-argument)
openstack_auth/user.py:362:4: E0211: Method has no argument (no-method-argument)
openstack_dashboard/api/keystone.py:75:4: C0412: Imports from package keystoneclient are not grouped (ungrouped-imports)
horizon/loaders.py:43:16: W0706: The except handler raises immediately (try-except-raise)
horizon/themes.py:174:8: W0706: The except handler raises immediately (try-except-raise)

Change-Id: I40cf3ffbc4519657e11180d2e2fe7401387c5556
2019-01-17 00:05:27 +09:00
Akihiro Motoki c076db20c8 pylint: fix len-as-condition warning
Change-Id: Ib89c1854ad42b96e4caf281160d568fe98430afe
2019-01-16 12:56:20 +09:00
wangliangyu ac88796410 Raise NotFound error when retrieved by not uuid
On identity-projects page:
  Retrieve project list filtered by id which is not uuid format like '%',
there will throw an error message on top-right page.
And the same for identity-users page.

It is reasonable that return an empty list without error prompt.

Change-Id: I65aec86f4d894a9789eef6fc093ed95a95c46d9f
Closes-Bug: #1800600
2018-10-30 16:03:56 +00:00
Radomir Dopieralski bdb3f9d988 Fix changing user's own password
The original code is monkey-patching keystoneclient object to add a
user_id attribute to it. This no longer works with more recent
versions of keystoneclient, as they wrap the client in a helper
class.

I'm not happy with this solution, it's likely to have side effects
and to break again. I'm putting it up for discussion for a better
solution.

Change-Id: Idb296d1b10fa02a0b4852e96fe8cb2bdd70380e0
Closes-bug: #1776678
2018-10-12 12:20:12 +02:00
Colleen Murphy 2d69444bad Add support for application credentials
This patch adds support for creating application credentials in
keystone[1]. Application credentials can be created by any user for
themselves. An application credential is created for the currently
selected project. A user may provide their own secret for the application
credential, or may allow keystone to generate a secret for them. After
the application credential is created, the secret is revealed once to
the user. At that point they may download a clouds.yaml or openrc file
that contains the application credential secret and will enable them to
use it to authenticate. The secret is not revealed again.

[1] https://docs.openstack.org/keystone/latest/user/application_credentials.html

bp application-credentials

Depends-On: https://review.openstack.org/557927
Depends-On: https://review.openstack.org/557932
Change-Id: Ida2e836cf81d2b96e0b66afed29a900c312223a4
2018-04-26 09:32:00 +02:00
Colleen Murphy 656490fee2 Add identity API version discovery
This patch adds a utility to the keystone API manager to retrieve the
identity endpoint's version data and retrieve the current version as a
tuple. As part of this work, this patch converts the deprecated usage of
keystoneclient alone to using keystoneclient in combination with a
keystoneauth session.

Change-Id: I37031b67ab2681e81022a75afcb4f41c5700c47b
2018-04-16 23:56:43 +02:00
Akihiro Motoki dd7e281844 Improve mocking in REST API tests (test_keystone)
The current REST API tests have a lot of rooms to be improved like:
- mocking the whole module of the API wrapper

Change-Id: I799b0bce11bb06f6da64b8cc76f490f644fd457f
Partial-Bug: #1752917
2018-03-22 06:24:44 +09:00
Shu Muto c174036c84 Add Change Password Action for Angular users panel
To Test
 - set 'users_panel' to True in settings.py

Change-Id: I779b26d34658ea5f3222ebf31f1401bc7a43960b
Partially-Implements: blueprint ng-users
2018-01-16 18:15:19 +09:00
Zuul 211c543fa4 Merge "Support include_names argument for keystone role assignement list" 2017-11-11 08:43:22 +00:00
Sam Morrison e98eb20555 Support include_names argument for keystone role assignement list
This has been supported in the keystone API since version 3.6
Although not used in horizon (yet) some third party plugins may
require this.

Closes-Bug: #1729449

Change-Id: I961c1681b757134037ae767ac750afa36476d630
2017-11-01 21:50:59 +00:00
Ivan Kolodyazhny 65baa5fa6d Do not fail on AdminUpdateRow if tenant is not found
We still can show instance info on admin/instances page even if tenant
is deleted or we can't retrieve tenant's information.

Change-Id: Idb1a5ffbb4103cce5258657d559bf4fe784b98d6
Closes-Bug: #1712565
2017-10-04 23:04:35 +03:00
Jenkins bfaa4e64ec Merge "Use publicURL as default of OPENSTACK_ENDPOINT_TYPE consistently" 2017-06-13 13:14:12 +00:00
Akihiro Motoki b9d0243c33 Fix H405 (multi line docstring) warnings (openstack_dashboard)
H405: multi line docstring summary not separated with an empty line

Closes-Bug: #1696996

Change-Id: Id895695663b19522d9cdc22f8b012e49680d708b
2017-06-09 16:05:31 +00:00
andrewbogott 0c775b73b3 keystone api: Fix a typo that broke the check for MULTIDOMAIN_SUPPORT
Change-Id: I3937bfc0e4a244daea2e26cc998e86d51bd07d91
2017-06-02 05:53:28 -05:00
Akihiro Motoki 49c6cdca92 Use publicURL as default of OPENSTACK_ENDPOINT_TYPE consistently
The current default settings of openstack_dashboard OPENSTACK_ENDPOINT_TYPE
has two default values 'publicURL' and 'internalURL' and this leads to
require both endpoints in deployments.

Having two default values for one setting is confusing. The comment in
local_settings.py says OPENSTACK_ENDPOINT_TYPE defaults to publicURL
and operators does not think internalURL is used.

I believe there is no negative side because if operators want to
deploy horizon out side of their OpenStack clouds they use publicURL
and if they want to deploy horizon behind load balancer or something
they would use internalURL as OPENSTACK_ENDPOINT_TYPE.

This also help the current devstack setup which only configures
public endpoint (interface) and Horizon does not work by default
for Identity dashboard.

Closes-Bug: #1686717
Change-Id: If5c7bbc5188f6df65661c41d777a9c7846fe9008
2017-04-27 13:31:31 +00:00
Gábor Antal 34a3aa0ba8 Handle log message interpolation by the logger
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I51f50935f1eeffe4960562d6309dfdf05814e595
Closes-Bug: #1596829
2017-03-31 20:59:16 +09:00
Timur Sufiev f09a9ce4c7 Use the new fix_auth_url_version_prefix() call
It is a variation of existing fix_auth_url_version() call which
returns as a second value a boolean flag indicating whether the
auth_url was fixed to point to /v3 endpoint. So we could display a
more clear message to deployers from Horizon, based on the value of
this flag. The legacy fix_auth_url_version() call is to be phased out
as soon as Horizon cease to depend on it. Also provide a release note
about removing the old function.

Change-Id: I6c6a35b1c460e22dadf39634fce1bdfa257b8c63
Depends-On: I3a04d838a707465c8c6e81e0e6e2fcf918b7b059
2016-12-16 14:48:32 +03:00
Jenkins 86bec0003e Merge "Wrap api calls with tracing decorators" 2016-12-02 11:59:40 +00:00
Jenkins e83069a2c3 Merge "Make default domain usage consistent" 2016-12-02 01:17:18 +00:00
Paul Karikh 97945b5f6a Wrap api calls with tracing decorators
Since Horizon is going to be the first (or, one of the first)
OpenStack component using the new MongoDB driver, it won't be able to
retrieve traces made by other components using MongoDB driver (which
it should use because Ceilometer driver was too slow) for a
while. This means that Horizon itself is responsible for tracing the
rendering of its pages down to the layer where the flow of control
leaves Horizon domain. So, a lot of api wrappers in
openstack_dashboard.api are augmented with tracing decorator to
achieve this goal.

Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Implements-blueprint: openstack-profiler-at-developer-dashboard
Change-Id: Ib36692f0e9e68ed7fa0cd47919ba6581c9c8ab57
2016-12-01 19:31:10 +00:00