Normalize endpoint path in oauth client

oauthlib uses the request URI as input for generating an oauth
signature and matching it against the incoming oauth_signature request
attribute. tempest also uses the URI to generate this signature, which
means the URIs must match exactly.

If the keystone catalog contains an endpoint with a trailing slash, such
as https://keystone.example.org/v3/, then the URI that tempest uses for
the signature generation will be
https://keystone.example.org/v3//OS-OAUTH1/request_token. The incoming
request URI that oauthlib sees will not have the duplicate slash and so
the resulting signature will differ, and the auth request will be
rejected due to mismatching HMAC-SHA1 signatures.

This patch corrects the issue for deployments that use a trailing slash
in their keystone catalogs (which is valid) by normalizing the path
before generating the signature.

Change-Id: Ie827b1af7b23c6d6eaf2c2894cc2629d0e252108
This commit is contained in:
Colleen Murphy 2019-02-12 15:43:59 +01:00
parent 00b8a6c204
commit 8b9980b497
1 changed files with 1 additions and 0 deletions

View File

@ -74,6 +74,7 @@ class OAUTHTokenClient(rest_client.RestClient):
scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri)
scheme = scheme.lower()
netloc = netloc.lower()
path = path.replace('//', '/')
normalized_uri = urlparse.urlunparse((scheme, netloc, path,
params, '', ''))