Commit Graph

33 Commits

Author SHA1 Message Date
Matthew Oliver 589ac355f3 Move *_swift_info functions into a new registry module
The *_swift_info functions use in module global dicts to provide a
registry mechanism for registering and getting swift info.

This is an abnormal pattern and doesn't quite fit into utils. Further
we looking at following this pattern for sensitive info to trim in the
future.
So this patch does some house cleaning and moves this registry to a new
module swift.common.registry. And updates all the references to it.

For backwards compat we still import the *_swift_info methods into utils
for any 3rd party tools or middleware.

Change-Id: I71fd7f50d1aafc001d6905438f42de4e58af8421
2022-02-03 14:41:13 +00:00
Tim Burke ba46eb0e3d py3: Fix non-ascii chars in staticweb listings
Change-Id: Ifcf810f009a8036f250a09eec0d9a65a77342129
Closes-Bug: #1894357
2020-09-06 22:04:06 -07:00
Tim Burke d03fc9bc54 swob: Stop auto-encoding unicode bodies
Instead, require that callers provide an encoding.

Related-Change: I31408f525ba9836f634a35581d4aee6fa2c9428f
Change-Id: I3e5ed9e4401eea76c375bb43ad4afc58b1d8006a
2018-06-28 09:58:44 -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
Alistair Coles 9c3c388091 Improve domain_remap docs
* Make the conditions for remapping clearer
* Mention the path_root
* Mention '-' -> '_' replacement in account names
* Make example consistent with default options

Change-Id: Ifd3f3775bb8b13367d964010f35813018b5b41b3
2017-08-18 09:23:45 +01: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
Ferenc Horváth 635bc7fa8f Replace string slicing with proper string methods
Updated string prefix and suffix checker slicing to startswith()
and endswith() methods.

Using startswith() and endswith() improves readability, error-proneness
and enhances maintainability.

Change-Id: I1d5fbf116a61763346c6f92fd8023dbbe9bb37cf
2015-11-27 14:09:35 +01: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
John Dickinson 1f7be20a91 pep8 middleware
Change-Id: Ieef65f05e66b12347752c0e02648858e3242d8e7
2012-11-20 14:51:55 -08: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 b47bcf19e4.

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 edf2637026 updated docs for domain remap and cname lookup middleware
Change-Id: I1c571951f25a6e724cdd4699eb94baad5e47eb95
2012-04-05 15:02:15 -05:00
John Dickinson 1ecf5ebba1 updated copyright date for all files
Change-Id: Ifd909d3561c2647770a7e0caa3cd91acd1b4f298
2012-03-19 13:45:34 -05:00
gholt 97c6ec6beb comment on domain_remap regarding container sync 2011-07-10 14:18:36 +00:00
gholt f57250ae11 pep8 and i18n fixes 2011-01-24 21:39:00 -08:00
Colin Nicholson 2ccc002851 fix small typo in domain_remap docs 2011-01-24 19:37:50 +00: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
Colin Nicholson 643476c3b0 changed domain_remap to handle multiple reseller prefixes 2011-01-21 10:11:38 +00:00
Colin Nicholson e76598fa58 Wrapped long line 2011-01-20 15:50:55 +00:00
Colin Nicholson 727a84d0dc Check account starts with correct case version of reseller_prefix. 2011-01-20 11:55:52 +00: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 73406ab0be pep8 2010-10-28 22:45:00 -05: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