Commit Graph

557 Commits

Author SHA1 Message Date
Zuul 733a34bcef Merge "Change retries log level to warning instead of info" 2024-01-05 17:09:25 +00:00
Stephen Finucane b68be4b70e Bump hacking, other flake8 plugins
Address the couple of small issues it highlights.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I0b0b8ff96d024cc3432ce902e781fff7e594924e
2023-12-18 10:20:25 +00:00
Stephen Finucane 9df23dc6a8 Bump bandit
Address incompatibility with Python 3.8, which happens due to the older
bandits use of the private '_ast' module instead of 'ast' [1] and the
deprecated 'Num' having been removed from the former. The bump requires
an additional nosec for a line that is misidentified as a hardcoded
password.

A note about requirements ordering is removed as it hasn't been relevant
since pip 20.3 introduced the new dependency resolver.

[1] 09b0207e2b

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Icaaa3a2e24429bba5cf70c04062cfa5820c8a1bf
2023-12-18 10:17:14 +00:00
Stephen Finucane b5ddc0732e Remove dependency on oslo_config
Per the note in requirements.txt, we do not want to depend on any oslo
library. Fix the accidental inclusion of this library.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I0287fc2493831e9b52790f7d6db13b8a4ed7158e
2023-12-14 10:44:36 +00:00
Zuul 2bc0f5afb0 Merge "Allow setting retriable status codes for Adapter via configuration options" 2023-12-01 16:29:25 +00:00
Jaromir Wysoglad 3b492a7aa0 Fix "dictionary changed size during iteration"
We have hit an error with
"dictionary changed size during iteration" a few times during
this week in telemetry integration tests. It seems like it's
hitting only our ubuntu based jobs, I haven't seen this error
in a centos based job yet. Example of the failed job can be
found in [1], I extracted a traceback, which leads to keystoneauth1
into [2]. According to [3] and [4] using copy() should help with
the issue. The python docs [5] indicate, that copy() should always
be used when iterating through sys.modules

[1] https://zuul.opendev.org/t/openstack/build/c99db592871a441e9cddad2f4e60c2fc/console
[2] https://paste.opendev.org/show/bpzng2EUyFh1tvBHczt7/
[3] https://github.com/python/cpython/issues/84507
[4] https://github.com/python/cpython/issues/89516
[5] https://docs.python.org/3/library/sys.html#sys.modules

Change-Id: I50500c6a21bbe60050303cea4628ca9b71a3e0eb
2023-11-09 10:37:37 -05:00
Pierre-Samuel Le Stang b43cad9353
Change retries log level to warning instead of info
Closes-bug: 2042670
Change-Id: Id771077b1070a80b9acab5ffda66155f0dea22be
2023-11-06 09:25:59 +01:00
Pierre-Samuel Le Stang f136680870
Allow setting retriable status codes for Adapter via configuration options
Signed-off-by: Pierre-Samuel Le Stang <pierre-samuel.le-stang@corp.ovh.com>
Change-Id: Id7ad3f398891361abe62027248eba0f5eb1934d7
2023-10-20 10:03:46 +02:00
Julia Kreger 74f05249d1 Drop parameters when connecting to a redirected endpoint
When redirected, the server *generally* returns a fully
formed URI, but does not really have to, so we may end up
in a "depending on how the redirect was triggered" would
result in the response handling.

Ultimately, any behavior which is not an fully formed URI
would be invalid.

But our code was taking the URI we got back, and would then
re-issue the request with a list of parameters with the new
URL. Duplicating the parameters on the URI.

Example of what was occuring, when only provision_state=active
was a parameter before the redirect:

/v1/nodes?provision_state=active&provision_state=active

Co-Authored-By: Kristi Nikolla <knikolla@bu.edu>
Co-Authored-By: Jay Faulkner <jay@jvf.cc>

Story: 2010029
Task: 45316
Change-Id: I4969a42ee651ac2c559e378d879b673a1d788c57
2023-10-06 16:21:02 +02:00
Zuul 659a288cc1 Merge "Keep request-id at redirect" 2023-10-02 11:44:36 +00:00
Zuul e6f3999c6f Merge "Support PKCE with v3oidcdeviceauthz" 2023-08-15 11:19:13 +00:00
Vadym Markov c800dcee75 Keep request-id at redirect
Currently when redirects are used, the request id can get lost on redirect.
Proposed patch reuses req-id from redirect response and passes it to
actual request

Closes-Bug: #2000742
Change-Id: I98d5d4490b3d5667677cdd19f3c7b39abe6044ef
2023-05-27 13:04:05 +00:00
Arvid Requate 38303c3c9f Support PKCE with v3oidcdeviceauthz
In case the OAuth 2.0 client for keystone is configured in Keycloak to
require PKCE (for horizon Web-SSO), this also applies to other flows
like v3oidcdeviceauthz.

https://www.rfc-editor.org/rfc/rfc7636

Signed-off-by: Arvid Requate <requate@univention.de>
Change-Id: I8475a583844d9b97ed65a9909c31cebc31cfbebb
2023-05-23 09:53:10 +02:00
Dave Wilde c69ade60a6 Remove last reference to the python six package
We missed an import of the six package.

Change-Id: Id618b93d47a6e25a89144b3a93b12cbb5fc14797
2023-05-17 09:35:24 -05:00
Zuul fe74dedb05 Merge "Make v3oidcpassword send client_id" 2023-05-16 16:23:11 +00:00
Steve Relf 30d61ad316 Make v3oidcpassword send client_id
Updates the v3oidcpassword function to also send the client_id as part of the request body,
this seems to be a requirement for services like onelogin.

Change-Id: I2392ef51302804c0c66c0fb52227db5f35bca3fd
2023-05-11 11:08:06 +00:00
Zuul 1462b7344e Merge "Add RFC required headers and data to the request" 2023-05-10 23:03:06 +00:00
Arvid Requate 3e15740c73 Add RFC required headers and data to the request
Fixup for 44e5b2deef

Signed-off-by: Arvid Requate <requate@univention.de>
Change-Id: I88bbfebd19f3e291c304f5bbd7f8dde2ed951821
2023-05-09 11:25:52 +02:00
Zuul 8d24892f9d Merge "Remove six" 2023-04-21 16:29:11 +00:00
Zuul bf5aed34cd Merge "Replace abc.abstractproperty with property and abc.abstractmethod" 2023-04-21 16:05:40 +00:00
Zuul 3ffea9276e Merge "Allow federation to work with unversioned auth_url" 2023-04-21 15:58:42 +00:00
Zuul b80a6b62e4 Merge "New auth plugin v3oidcdeviceauthz" 2023-03-03 17:10:06 +00:00
Arvid Requate 44e5b2deef New auth plugin v3oidcdeviceauthz
OAuth 2.0 Device Authorization Grant

https://www.rfc-editor.org/rfc/rfc8628

Signed-off-by: Arvid Requate <requate@univention.de>
Change-Id: I8344ee5c9730c1533d58d7ccb04ddc3d2d517ade
2023-02-23 10:09:08 +01:00
sunyonggen ca28df8480 OAuth 2.0 Mutual-TLS Support
Added a new OAuth2mTlsClientCredential plugin, accessible via the
'v3oauth2mtlsclientcredential' entry point, making possible to
authenticate using an OAuth 2.0 Mutual-TLS client credentials.

Co-Authored-By: Hiromu Asahina <hiromu.asahina.az@hco.ntt.co.jp>
Change-Id: I0e02ef18da5d60cdd1bcde07b07c2071b74b73d6
Implements: blueprint support-oauth2-mtls
2023-02-10 20:56:45 +09:00
Zuul c96b058212 Merge "Enforce scope mutual exclusion for system" 2022-12-20 22:37:30 +00:00
Grzegorz Grasza 5098d45cca Allow passing of version header
Add keyword option to get_version_data() to allow passing
of the version header so that we can get the microversions.
Specifically, this is so that we can re-use this function
in barbican, which recently implemented microversions, but
doesn't return them by default, for backward compatibility
with old clients.

Change-Id: I909750381a559f9dc61650c9f98c88d4481012b7
2022-12-20 15:58:04 +01:00
Stephen Finucane 192a27ae5f Remove six
This is no longer necessary since we only support Python 3.x.

A note is removed from requirements.txt since it's no longer relevant:
pip 20.3+ has a real dependency resolver.

Change-Id: Ie3006813a79fef1f128d388b906e4f1752347fa4
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Co-Authored-By: Grzegorz Grasza <xek@redhat.com>
2022-12-14 10:47:25 +00:00
Pavlo Shchelokovskyy 737790f732 Allow federation to work with unversioned auth_url
while e.g. V3Password works perfectly fine with unversioned auth_url
like 'http://keystone', everything based on FederationBaseAuth
does not and only requires versioned v3 auth_url.

Since OS_FEDERATION is implemented only in v3, this patch
makes sure that federated_token_url has v3 in it, thus allowing
for unversoned auth_url as well.

Closes-Bug: #1998366
Change-Id: I1f0b00b6f721c53bb5308e03223d0c1564ca81b3
2022-12-02 18:04:08 +00:00
Pavlo Shchelokovskyy ae646f8d37 Enforce scope mutual exclusion for system
we already fail when mutliple scope identifiers are provided, however
not when system scope is involved. As a result of the undocumented
priority of checks, when system scope is specified together with any
other scope, that other scope will silently be used.

Change-Id: I120ed63f6c1262d067eeb6168feab35278cacf6a
2022-12-02 18:03:47 +00:00
Hervé Beraud 11faa0e67d Fix linters and bindep on jammy
Bump linter requirements - follow the changes
made in keystone in commits
6dfde5b48b388e32e34a385c3a9ef48da7c7c49b and
5c71ebd7a92d25df83e2e7cc5fad9990e9eebbf5 in
order to fix compatibility with Python 3.10.

Remove python-dev from bindep - it's no longer
supported by jammy and lead us to the following
errors with the announce-release job:

```
No package matching 'python-dev' is available
```

Co-Authored-By: Herve Beraud <hberaud@redhat.com>
Change-Id: If687a2678733ce018bd31c602140f073ab1a1a65
2022-12-01 12:14:33 +00:00
Yi Feng aa9c5d230f OAuth2.0 Client Credentials Grant Flow Support
Added a new OAuth2ClientCredential plugin, accessible via the
'v3oauth2clientcredential' entry point, making possible to authenticate
using an application credentials as an OAuth2.0 client credentials.

Change-Id: I77d6faef4cbc75abb8e7d86f386fb6d16e40cabf
2022-08-30 06:29:20 +00:00
ljhuang be2223c0f8 Replace abc.abstractproperty with property and abc.abstractmethod
Replace abc.abstractproperty with property and abc.abstractmethod,
as abc.abstractproperty has been deprecated since python3.3[1]

[1]https://docs.python.org/3.8/whatsnew/3.3.html?highlight=deprecated#abc

Change-Id: I506bd4f17d9c86d1a0328e765e8c695c76e16f18
2022-08-03 17:53:44 +08:00
Zuul f194e6a820 Merge "Allow logging of Content-Type text/plain" 2022-05-13 17:11:37 +00:00
Zuul 12a84e1919 Merge "Fix version discovery check of url for integer project id" 2022-05-13 17:11:35 +00:00
Zuul cc58eca84f Merge "Improve help messages for a few options" 2022-05-06 17:13:28 +00:00
Zuul 97477c3261 Merge "User-friendly error message for DiscoveryFailure" 2022-05-06 17:07:04 +00:00
melanie witt bc491817e1 Allow logging of Content-Type text/plain
Noticed this while doing some local testing, if a WSGI app replies with
a text/plain content type to communicate a server error, we aren't able
to see the error response message when passing --debug to the
openstackclient, example:

  RESP: [500] Date: Thu, 01 Oct 2020 23:54:15 GMT Server: Apache/2.4.18
  (Ubuntu) Content-Type: text/plain; charset=UTF-8 Connection: close
  Transfer-Encoding: chunked
  RESP BODY: Omitted, Content-Type is set to text/plain; charset=UTF-8.
  Only application/json responses have their bodies logged.

Change-Id: Ibfd46c7725bd0aa26f1f80b0e8fc6eda2ac2e090
2022-04-29 15:57:52 +00:00
Simon Li 1a138049f7 fix: miss attr _discovery_cache in ServiceTokenAuthWrapper
Add the super method to the ServiceTokenAuthWrapper class
to get the _discovery_cache attribute of the parent class.

the error info is below while neutron is authenticated by
keystoneauth plug in task inspector enroll baremetal node:
ERROR oslo_messaging.rpc.server:
Exception during message handling: AttributeError:
'ServiceTokenAuthWrapper' object has no attribute '_discovery_cache'

Change-Id: Icc7c4e25a123b5565c94f43f932ee32f9f304a76
2022-04-29 15:52:47 +00:00
Dylan McCulloch 8e27ff5d13 Fix version discovery check of url for integer project id
Check if the last url segment matches the project id.
Previously the check only confirmed whether the last url segment
endswith the project id which could cause problems with spurious
matches of some legacy integer project ids.

Closes-Bug: 1968793
Change-Id: I7c6c22e41bde2a73508635b7e964c58a02c12146
2022-04-13 09:43:29 +10:00
Cyril Roelandt bb7c630504 Improve help messages for a few options
Closes-Bug: #1962037
Change-Id: If082a7f4cc09ffc42c68081dd43c2808b6c5f8a9
2022-02-23 20:59:08 +01:00
Dmitry Tantsur a3b4718233 User-friendly error message for DiscoveryFailure
The passage about discovery document and allow_version_hack makes little
sense for people unfamiliar with keystoneauth internals. What it
actually means in most cases is that the remote service is not
available. Rephrase the error message and add some debug logging.

Change-Id: I156dbb45bd8c07ace1900894f6779ed9f38cf3c6
2022-01-20 16:57:58 +01:00
Goutham Pacha Ravi 112bcae1fb Specify manila microversion header
Manila API honors a "X-OpenStack-Manila-API-Version"
header to specify microversions.

It may support the OpenStack-API-Version header
in a future release, however, we'll need to maintain
backwards compatibility with the existing API.

Change-Id: Ia2e62d3a11a08adeb6d488b7c9b365f7ff2be3c8
2021-02-18 08:38:29 -08:00
Dmitry Tantsur d21c52867f Provide the default get_auth_ref implementation
osc-lib tries to call it, failing for e.g. http_basic.

Change-Id: Iacfba0940beda4dce2a9be0c863cb506d4013e2f
2020-09-17 12:28:35 +02:00
Dmitry Tantsur 981a19bba1 Correct major version discovery for non-keystone plugins
When a non-keystone plugin is used together with an unversioned endpoint,
we give up on discovery before figuring out both major version and
the correct endpoint. This is because get_endpoint_data is called with
discover_versions=False, so discovery assumes we have all information
already. It may be an issue in discovery itself, but I'm afraid to
touch that code. Instead, if get_endpoint_data returns no API version
with discover_versions=False, try with discover_versions=True, which
matches what the identity plugins do.

Also increase the unit test coverage.

Change-Id: Ie623931b150748d7759cf276e0023a2f06a8d4db
2020-07-31 11:32:26 +02:00
Monty Taylor b95a89e3ff Fix get_endpoint_data for non-keystone plugins
We expect endpoint_override, but these plugins won't necessary
have it, they have endpoint instead.

Co-Authored-By: Dmitry Tantsur <dtantsur@protonmail.com>
Change-Id: Iead4b95c1f5b8d84cec705da32f41049e2eea641
2020-07-27 17:20:58 +02:00
Steve Baker ff68663217 Implement HTTP Basic client support in keystoneauth1
A new basic auth plugin is added which enables HTTP Basic
authentication for standalone services. Like the noauth plugin, the
endpoint needs to be specified explicitly, along with the
username and password.

An example of a standalone server implementing HTTP Basic can be seen
in Ironic change https://review.opendev.org/#/c/727467/

Change-Id: Ib3f0a9c518d031a67f9605cf64a8a9cc81131ed3
Story: 2007656
Task: 39741
2020-06-15 10:26:35 +12:00
Zuul 94314329e9 Merge "Replace assertItemsEqual with assertCountEqual" 2020-06-05 04:45:24 +00:00
Zuul e96c2102ad Merge "Use unittest.mock instead of third party mock" 2020-06-05 04:21:48 +00:00
Zuul 1f0412a042 Merge "Make header Case Insensitive" 2020-06-03 17:57:33 +00:00
Joel Capitao 1fe8df2bc8 Replace assertItemsEqual with assertCountEqual
assertItemsEqual was removed from Python's unittest.TestCase in
Python 3.3 [1][2]. We have been able to use them since then, because
testtools required unittest2, which still included it. With testtools
removing Python 2.7 support [3][4], we will lose support for
assertItemsEqual, so we should switch to use assertCountEqual.
Credits to [5].

[1] - https://bugs.python.org/issue17866
[2] - https://hg.python.org/cpython/rev/d9921cb6e3cd
[3] - testing-cabal/testtools#286
[4] - testing-cabal/testtools#277
[5] - https://review.opendev.org/#/c/732393/

Change-Id: Ib1db7694a8f0f59d8762b02acbb4ef16e5176098
2020-06-03 15:14:41 +02:00