22 Commits

Author SHA1 Message Date
Tim Burke
efcf7e6a95 swob: Fix up some WSGI string business
Change-Id: Iee1bab5775b243c318aa22ee4a548d793e6684ca
2018-06-27 15:55:30 -07:00
Samuel Merritt
306f9a150f py3: port domain_remap tests
The domain_remap middleware didn't need to change, only its tests.

Change-Id: I5edf05b609ce263708f851219c38c1bd1b645a6f
2018-06-26 13:20:49 -07:00
Tim Burke
94bac4ab2f domain_remap: stop mangling client-provided paths
The root_path option for domain_remap seems to serve two purposes:
 - provide the first component (version) for the backend request
 - be an optional leading component for the client request, which
   should be stripped off

As a result, we have mappings like:

   c.a.example.com/v1/o -> /v1/AUTH_a/c/o

instead of

   c.a.example.com/v1/o -> /v1/AUTH_a/c/v1/o

which is rather bizarre. Why on earth did we *ever* start doing this?

Now, this second behavior is managed by a config option
(mangle_client_paths) with the default being to disable it.

Upgrade Consideration
=====================

If for some reason you *do* want to drop some parts of the
client-supplied path, add

   mangle_client_paths = True

to the [filter:domain_remap] section of your proxy-server.conf. Do this
before upgrading to avoid any loss of availability.

UpgradeImpact
Change-Id: I87944bfbf8b767e1fc36dbc7910305fa1f11eeed
2017-10-09 23:36:33 +00:00
Tim Burke
849d204c59 domain_remap: be more careful about client-path mangling
The root_path option for domain_remap seems to serve two purposes:
 - provide the first component (version) for the backend request
 - be an optional leading component for the client request, which
   should be stripped off

As a result, we have mappings like:

 c.a.example.com/     -> /v1/AUTH_a/c/
 c.a.example.com/o    -> /v1/AUTH_a/c/o
 c.a.example.com/v1/o -> /v1/AUTH_a/c/o

Currently, we don't really care about whether there was a full- or
partial-match in that first component, leading to mappings like

 c.a.example.com/v1o  -> /v1/AUTH_a/c/o

If we're going to continue supporting that second function, we should
only consider full-matches, so we'll have

 c.a.example.com/v1o  -> /v1/AUTH_a/c/v1o

Change-Id: Ibdc97bb8daf117ad46177617f170d03e481b0007
2017-06-01 13:57:32 -07:00
Romain LE DISEZ
107ba79770 Rewrite redirection in cname_lookup & domain_remap
cname_lookup and domain_remap are currently not catching redirections
(eg: staticweb). This behavior makes the domain to change when a call
through cname_lookup and domain_remap end up being redirected. Example:
commit fixes it.
 - original request: http://mysite.com/subdir
 - redirected:  http://cont.acct.storage.domain.com/v1/AUTH_acct/cont/subdir/
 - expected: http://mysite.com/subdir/

This patch is fixing this.

Closes-Bug: #1190625
Co-Authored-By: Tim Burke <tim.burke@gmail.com>
Change-Id: I67f642b8b070bc21e7760477d0a1e3b902ba7896
2017-05-11 09:46:29 -04:00
Romain LE DISEZ
6db12b87ff Fix domain_remap when obj starts/ends with slash
domain_remap strip all starting/ending slashes. This behavior does not
allow to access objects starting or ending with slash. It is also
impacting staticweb middleware as staticweb tries to redirect
pseudo-directory to an URL with an ending slash, but as domain_remap
strip it, it goes to an infinite loop.

With this commit, the path of the request is passed as-is when
reconstructing the new request path. Example
http://www.example.com//obj/ was previously rewritten to
http://storage.example.com/v1/AUTH_abc/container/obj. It is now
rewritten to http://storage.example.com/v1/AUTH_abc/container//obj/

Closes-Bug: #1682293
Co-Authored-By: Christian Schwede <cschwede@redhat.com>
Change-Id: I1ef6b8752183d27103a3b0e720edcb4ce06fb837
2017-05-11 08:47:23 -04:00
Romain LE DISEZ
5c93d6f238 Accept storage_domain as a list in domain_remap
Middleware domain_remap can work with cname_lookup middleware. This last
middleware accept that storage_domain is a list of domains. To be
consistent, domain_remap should have the same behavior.

Closes-Bug: #1664647

Change-Id: Iacc6619968cc7c677bf63e0b8d101a20c86ce599
2017-02-18 10:41:27 +01:00
janonymous
f5f9d791b0 pep8 fix: assertEquals -> assertEqual
assertEquals is deprecated in py3, replacing it.

Change-Id: Ida206abbb13c320095bb9e3b25a2b66cc31bfba8
Co-Authored-By: Ondřej Nový <ondrej.novy@firma.seznam.cz>
2015-10-11 12:57:25 +02:00
John Dickinson
e87a74695e add domain_remap to /info
Also added the value of default_reseller_prefix to /info. I did not
add the reseller_prefixes value to /info because deployers may not
want to expose all of the resellers that are available.

Change-Id: I9ca2f002dc395913bb646390d6908dfb8f554df1
2015-07-07 21:18:19 -07:00
Koert van der Veer
11e5c4adf0 Allow default reseller prefix in domain_remap middleware
Previously, the reseller prefix needed to be provided in the host name
even when the domain was unique to that reseller. With the
default_reseller_prefix, any domain which matches in this middleware,
will will be passed on with a reseller prefix, whether or not it was
provided.

Change-Id: I5aa5ce78ad1ee2e3660cce4c3e07306f8999f02a
Implements: blueprint domainremap-reseller-domains
2015-06-06 12:54:41 -07:00
John Leach
85c91a4e82 Allow empty reseller prefixes in domain_remap
Change-Id: I2013e4686fce1c06626ec974f8d721721e6ca6e7
2014-04-23 23:59:28 +01:00
ZhiQiang Fan
f72704fc82 Change OpenStack LLC to Foundation
Change-Id: I7c3df47c31759dbeb3105f8883e2688ada848d58
Closes-bug: #1214176
2013-09-20 01:02:31 +08:00
Eohyung Lee
04037aee5d Fixed bug in domain_remap and cname_lookup middleware
If domain_remap and cname_lookup received request which has no host header,
then returns 500 error. This fixes that problem.

Change-Id: Ibb457e9b4cb21181d8243858c04ce255365690da
Fixes: bug #1100632
2013-01-23 09:36:37 +09:00
Michael Barton
5e3e9a882d local WSGI Request and Response classes
This change replaces WebOb with a mostly compatible local library,
swift.common.swob.  Subtle changes to WebOb's API over the years have been a
huge headache.  Swift doesn't even run on the current version.

There are a few incompatibilities to simplify the implementation/interface:
 * It only implements the header properties we use.  More can be easily added.
 * Casts header values to str on assignment.
 * Response classes ("HTTPNotFound") are no longer subclasses, but partials
   on Response, so things like isinstance no longer work on them.
 * Unlike newer webob versions, will never return unicode objects.

Change-Id: I76617a0903ee2286b25a821b3c935c86ff95233f
2012-09-28 14:48:48 -07:00
John Dickinson
1e90b61076 Re-add cname lookup and domain remap middleware
Revert "removed cname lookup middleware"

This reverts commit b47bcf19e41e862ca84d77a7b8843f836e084b6a.

Revert "removed domain remap middleware"

This reverts commit 317cf868bdf66dbc17c02d4ca383efafa5e2f229.

Change-Id: I260498d555c93b28896ace48a6f0e96701cbcc38
2012-05-21 20:02:04 -05:00
John Dickinson
7dfbd785b0 removed domain remap middleware
The code has moved to https://github.com/notmyname/swift-domainremap.

For current users of domain remap, this will require installing the new
package and changing the "use" line of the domain remap conf section's
to:

[filter:domain_remap]
use = egg:swift_domainremap#swift_domainremap

And then 'swift-init proxy reload'.

Change-Id: I710caf9b991f9d37df36b826ae4338086d0ec36d
2012-05-08 21:30:35 -05:00
John Dickinson
1ecf5ebba1 updated copyright date for all files
Change-Id: Ifd909d3561c2647770a7e0caa3cd91acd1b4f298
2012-03-19 13:45:34 -05:00
John Dickinson
918d5feaa8 changed domain_remap to use an exclusive list in reseller_prefixes. added tests 2011-01-24 13:24:47 -06:00
Anne Gentle
8823427161 Changed copyright notices on py files and the single rst file with a copyright notice 2011-01-04 17:34:43 -06:00
gholt
67504c595a PEPy fixes 2010-11-03 09:04:44 -07:00
gholt
d13b3b318d domain_remap bugfixes 2010-11-03 08:56:58 -07:00
John Dickinson
508ebca777 domain remap middleware that maps account and container references in the domain to the path 2010-10-28 22:41:38 -05:00