23 Commits

Author SHA1 Message Date
Samuel Merritt
a7604da065 Move multipart MIME parser into utils
Over on the EC branch, we need to be able to parse multipart MIME
documents in the object server. The formpost middleware has a
perfectly good MIME parser, but it seems sort of awful to import
things from formpost in swift/obj/server.py, so I pulled it out into
common.utils.

Change-Id: Ieb4c05d02d8e4ef51a3a11d26c503786b1897f60
2014-09-16 10:10:59 -07:00
Richard (Rick) Hawkins
d2a94bd43c Fix FormPOST max_file_size exceeded bug.
When using FormPOST, if the size of the file being posted exceeds
max_file_size, a HTTP 499 was being returned rather than HTTP 400.

Change-Id: I48c781735c66eccde3deb6f9c3c184aee964a4a5
2014-09-08 21:34:40 -05:00
Matthew Oliver
90272a0564 Add X-Delete-At/After support to FormPost
This change adds the ability to specify a X-Delete-At or
X-Delete-After attribute when using the FormPost middleware.

Here is an example of what you need to add to the form:

  <input type="hidden" name="x_delete_at" value="<unix-timestamp>"/>
  <input type="hidden" name="x_delete_after" value="<seconds>"/>

To be inline with the other form imput names, x-delete-at/after has
changed to x_delete_at/after.

DocImpact
Change-Id: Ib1cc0bcf1dd7d2b689f2f26d100f9bab36880c81
Closes-Bug: #1065522
2014-07-18 15:41:21 -07:00
Samuel Merritt
7829ca07d7 Remove some debugging prints from tests
Change-Id: I7116aa75ea5c8e1ef85a799a6e1ddf0d6edffb4f
2014-03-18 12:50:51 -07:00
David Goetz
56c902c8de form post over XMLHttpRequest (cors) broken
Change-Id: Ia55e0d3974a96e11d49ab3cb26b6dcd7129b5cc8
2013-10-28 22:38:53 +00:00
Donagh McCabe
9807a358c6 Add WWW-Authenticate to 401 responses
Per http://www.ietf.org/rfc/rfc2616.txt, when a 401 error is returned, the
Www-Authenticate response header MUST also be returned. The format is
described in http://www.ietf.org/rfc/rfc2617.txt.

Swift supports and/or implements a number of authentication schemes
including tempauth, Keystone, tempurl, formpost and container sync. In
this fix, we use a catch-all, "Swift". The realm is the account (where
known) or "unknown" (bad path or where the 401 is returned from code
that does not have the request). Examples:

     Www-Authenticate: Swift realm="AUTH_1234567889"
     Www-Authenticate: Swift realm="unknown"

Fixes bug #1215491

Change-Id: I03362789318dfa156d3733ef9348795062a9cfc4
2013-10-22 15:49:09 +01:00
ZhiQiang Fan
f72704fc82 Change OpenStack LLC to Foundation
Change-Id: I7c3df47c31759dbeb3105f8883e2688ada848d58
Closes-bug: #1214176
2013-09-20 01:02:31 +08:00
Dirk Mueller
3d36a76156 Use Python 3.x compatible except construct
except x,y: was deprected and is removed in Python 3.x.
Use "except x as y:" instead which works in any Python
version >= 2.6.

Change-Id: I7008c74b807340f3457d3a0c8bd0b83f23169d14
2013-09-07 10:50:54 +02:00
Peter Portante
be1cff4f1f Pep8 unit test modules w/ <= 10 violations (5 of 12)
Change-Id: I8e82c14ada52d44df5a31e08982ac79cd7e5c969
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-09-01 15:12:48 -04:00
Alex Gaynor
ff5a6d0111 Corrected many style violations in the tests.
I focussed primarily on F-category violations, they are all but all fixed with
this patch.

Change-Id: I343f6945c97984ed1093bc347b6def6994297041
2013-07-24 10:18:47 -07:00
Samuel Merritt
bd00f0c8c9 Make formpost work with multiple tempurl keys.
Formpost wouldn't look at X-Account-Meta-Temp-URL-Key-2 for signature
validation, which was confusing to users. Now it does, and there's a
utility function that formpost and tempurl both use to help prevent
divergence in the future.

Also removed formpost's custom cache-lookup logic. Formpost was
looking for tempurl keys in memcache, but it's been broken since
commit 21343ab (2013-05-02) when tempurl changed its memcache keys, so
the lookup would always miss. (Since tempurl started storing *lists*
of keys, formpost would have choked on the new data, so that oversight
was the only thing keeping formpost working at all.)

Now formpost just uses the same get_account_info() call as everyone
else does, so it gets all the benefits of the new caching framework.

Change-Id: I426d8f2882ebe3ce373de604b9ff18846f5999e3
2013-06-26 11:44:48 -07:00
Chmouel Boudjnah
d462393944 Fix formpost with queries without user_agent.
- Fixes bug 1190220.

Change-Id: I3d46cc8f26ce9970dacb82bc5243b3528788c785
2013-06-12 21:02:08 +02:00
Greg Lange
44f00a23c1 fixed some minor things in tests that pyflakes complained about
Change-Id: Ifeab56a964630bcf941e932fcbe39e6572e62975
2013-03-26 20:42:26 +00:00
gholt
ffada71137 Fixed formpost QUERY_STRING bugs.
Ensures that any QUERY_STRING to FormPost is not passed onward.
Handles a redirect with a query string properly.

Change-Id: If0a7d9b0a17314c6cd3852175362d4633f828d81
2013-02-19 19:55:50 +00:00
Chuck Thier
e88ff34685 Cleanup of file permissions
Mostly removed execute on non-executable files

Change-Id: Ibfbe7e0cf0fbeabef602d70b20f75e1dd3bdf9c9
2013-02-15 11:06:11 -06:00
Tong Li
2267b030bf Swift MemcacheRing (set) interface is incompatible fixes
This patch fixes the Swift MemcacheRing set and set_multi
interface incompatible problem with python memcache. The fix
added two extra named parameters to both set and set_multi
method. When only time or timeout parameter is present, then one
of the value will be used. When both time and timeout are present,
the time parameter will be used.

Named parameter min_compress_len is added for pure compatibility
purposes. The current implementation ignores this parameter.

To make swift memcached methods all consistent cross the board,
method incr and decr have also been changed to include a new
named parameter time.

In future OpenStack releases, the named parameter timeout will be
removed, keep the named parameter timeout around for now is
to make sure that mismatched releases between client and server
will still work.

From now on, when a call is made to set, set_multi, decr, incr
by using timeout parametner, a warning message will be logged to
indicate the deprecation of the parameter.

Fixes: bug #1095730
Change-Id: I07af784a54d7d79395fc3265e74145f92f38a893
2013-02-13 13:56:04 -05: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
gholt
d8c2d0e1bc FormPost logging bugfix and slight refactor
In the interest of getting us to pep8 1.3.1 compliance I also fixed
all violations in the two files I was modifying anyway.

Fixes bug 1019051

Change-Id: I52eb7d59d2e2810a8cee2461f7ca869124e734e7
2012-07-03 19:04:40 +00:00
gholt
1c3b75c291 Reverted the pulling out of various middleware:
RateLimit
StaticWeb
TempURL/FormPOST

Change-Id: I988e93e6f4aacb817a2e354d43a04e47516fdf88
2012-05-16 21:25:10 +00:00
gholt
c0532a6ef2 Pulled out TempURL/FormPOST
TempURL/FormPOST is now at http://gholt.github.com/swift-tempurl/

For current users of TempURL/FormPOST, this will require installing the new
package and changing the "use" line of the tempurl and formpost conf section's
to:

[filter:tempurl]
use = egg:swifttempurl#tempurl

[filter:formpost]
use = egg:swifttempurl#formpost

And then 'swift-init proxy reload'.

Change-Id: I5bddf7f9e09ee07815530a41c46ff901fc21b447
2012-05-08 20:20:29 +00:00
gholt
0ec5eef916 Update middleware to use common pre_authed funcs
Update StaticWeb, FormPost, and TempURL to use common
make_pre_authed_env and make_pre_authed_req functions.

Change-Id: I32cc3cddff0d2aaeb6314578872707c1a37b4bce
2012-03-29 07:24:17 +00:00
gholt
22ea604b94 tempurl and formpost set REMOTE_USER
This is to allow them to pass through staticweb.

Change-Id: I421b1dba89b298c6dbd8e99d7aa8d4e98f0c28e3
2012-02-09 02:49:14 +00:00
gholt
7fc1721d7d TempURL and FormPost Middleware
Change-Id: I8d2ce2abdfe3a44605c9441ad7b1abc6c77e282d
2012-01-10 21:57:52 +00:00