Commit Graph

90 Commits

Author SHA1 Message Date
Ondřej Nový 022f688a7c Retire swauth
Change-Id: Ib8e22a1e2e35d22a754943e34501305a0cfdd9b9
Depends-On: https://review.opendev.org/678368
See: http://lists.openstack.org/pipermail/openstack-discuss/2019-August/008416.html
2019-08-24 20:04:50 +02:00
Tim Burke 50b8688e7e Use stdlib urlparse
The wrapper swift wrote for IPv6 support hasn't been necessary since
dropping support for Python 2.6 back in 2015. See

- https://github.com/openstack/swift/commit/67de0c8
- https://github.com/python/cpython/commit/8c6d9d7
- https://bugs.python.org/issue2987

Drive-by: use range() since xrange() doesn't exist on py3 and we're only
going to 16; clean up an invalid escape sequence.

Change-Id: Ib124cb27edd4c3defdb4a9e2404dcdcb71e6dd99
2019-05-10 11:04:29 -07:00
Vu Cong Tuan 0c8eaf50a9 Replace unicode with six.text_type
The unicode() built-in does not exist under Python 3 so use
six.text_type, which is set correctly to str or unicode, instead.

Change-Id: Ieb29486c99400b4a10ce642cb3adc83f5e4420f6
2018-07-05 11:14:12 +07:00
Tim Burke 2a84fe7c69 Stop using client headers for cross-middleware communication
Previously, Swift3 used client-facing HTTP headers to pass the S3 access
key, signature, and normalized request through the WSGI pipeline.
However, swauth did not validate that Swift3 actually set the headers;
as a result, an attacker who has captured a single valid request through
the S3 API may impersonate the user that issued the request indefinitely
through the Swift API.

Now, the S3 authentication information will be taken from a separate,
client-inaccessible namespace in the WSGI environment as defined in the
related change.

UpgradeImpact

This addresses a breaking API change in Swift3. No currently deployed
version of Swift3 will work with this. When upgrading swauth, operators
will need to upgrade Swift3 as well.

Change-Id: Ie5481a316397f46734e9dd0e77a8a87197ceec16
Related-Change: Ia3fbb4938f0daa8845cba4137a01cc43bc1a713c
2017-12-09 15:54:01 +00:00
Pavel Kvasnicka 70af798626 Hash token before storing it in Swift
Swauth uses token value as object name. Object names are logged in proxy
and object servers. Anybody with access to proxy/object server logs can
see token values. Attacker can use this token to access user's data in
Swift store. Instead of token, hashed token (with HASH_PATH_PREFIX and
HASH_PATH_SUFFIX) is used as object name now.

WARNING: In deployments without memcached this patch logs out all users
because tokens became invalid.

CVE-2017-16613

SecurityImpact
Closes-Bug: #1655781
Change-Id: I0d01e8e95400c82ef25f98e2d269532e83233c2c
2017-11-21 12:01:22 +01:00
Ondřej Nový 2d22f804a7 Fixed typo in docstring
Change-Id: Ib635eac542b26573560e714449960176380fa4fa
2016-11-21 16:40:40 +01:00
Ondřej Nový bb377d790d Don't ignore logger exception
Change-Id: I4a5001bf47b5910c1a543cbe5462758381274eb0
2016-10-29 15:14:29 +02:00
Prashanth Pai 26cf5aa107 s3: Make s3 support configurable
Amazon S3 compatibility:
Due to security concerns raised, this change makes S3 support tunable
using a config option and is turned off by default.

Change-Id: I077f78946983f5d6b3b725dd6aa3ed178dc5604e
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2016-07-28 23:07:35 +05:30
Prashanth Pai 5d15daaab6 Don't include salt in HMAC computation
Currently, the input to HMAC function is the entire stored credential
in the format '<salt>$<hash>` but it should rather be only the hashed
key/password.

With this change, validate_creds() method is invoked and only the hash
of the password is used in HMAC computation.

Change-Id: I1a9bbcac6f49c23f3256572f148e55249a59f7ed
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2016-06-07 15:12:27 +05:30
Ondřej Nový 5c76099efd More authtypes validation checks
Change-Id: I47e139dc100333e2befc362196ede1b238ee0588
2016-05-31 20:42:16 +02:00
Peter Lisák 07d1c0a3d0 creds validation function
Change-Id: Iae92c06b2f24a6ca80d98513cc54f3ca6910afa8
2016-05-31 17:00:48 +02:00
Ondřej Nový b548d3dcf7 Add support for setting already hashed password
You can use this for restoring dumped users list from swauth-list
command.
Change-Id: Ia77d7a0b91b2f79999286858e383477a80d7db15
2016-05-24 12:08:38 +02:00
Jenkins 19f9beeb9d Merge "Fix changing of auth_type in existing deployments" 2016-03-08 10:26:55 +00:00
Jenkins 64eab78a92 Merge "Allow configuring salt manually" 2016-03-08 09:27:13 +00:00
Prashanth Pai e0b0292a27 Allow configuring salt manually
Older versions of swauth supported manually setting up a salt string in
conf file. This change re-introduces it and makes it a tunable option.

The current behavior of randomly generating salt for every password is
NOT affected with this change.

Change-Id: Ifdf6f806b954e4d41c083eeffa981cd7d0dd50b9
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2016-02-29 11:49:11 +05:30
Prashanth Pai e40938cbb4 Fix changing of auth_type in existing deployments
Problem:
If an existing swauth deployment changes `auth_type` in conf file to a
different one (for example: sha1 to sha512), all attempts to authorize
existing/old users will fail because of change in encoder type.

Fix:
With this change, the credentials match is done using an encoder with
which the password was initially encoded. This allows swauth deployments
to change auth_type and old users will still be able to authorize.

Closes-Bug: 1516980
Change-Id: I8a5c397d0796062f4109c59b6dc61b14d4a97e4b
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2016-02-29 10:30:32 +05:30
Prashanth Pai 2e4c9f954a Don't pass unicode to hmac.new()
This issue can be hit when swift3 middleware is in the pipeline.

Change-Id: If87a6663efcf31febe4a207b3d7f331b5f79b834
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2016-02-26 12:58:20 +05:30
Ondřej Nový f195a5f6ec Fixed E127 and E131 hacking.
E127 continuation line over-indented for visual indent
E131 continuation line unaligned for hanging indent

Change-Id: I19ceb58d8545fb1b585e04b40418271f6ff56a5e
2016-02-14 14:27:33 +01:00
Brian Cline 556aa15697 Use correct content type on JSON responses
Currently, in cases where swauth returns a JSON document as its body,
it does not specify a content type, and swob defaults it to text/html.

This change uses a standard content type of 'application/json' in each
of these instances, and adjusts the tests accordingly.

Closes-Bug: #1545430
APIImpact

Change-Id: I96d343a87f462811bcefb7d402887f8a570fe6bd
2016-02-14 06:41:21 -06:00
Ondřej Nový 4b481e3777 Python 3 deprecated the logger.warn method in favor of warning
DeprecationWarning: The 'warn' method is deprecated, use 'warning'
instead

Change-Id: I1905a91aefc9e7e39a9874c1c4e1710d0d6733c0
2015-12-18 17:52:42 +01:00
Jenkins 75a31c23e5 Merge "Automagic versioning" 2015-12-15 11:36:40 +00:00
Ondřej Nový 375b430fff Automagic versioning
Use pbr for versioning when developing but use
PKG-INFO file in production. This lets you build
swauth package that don't require pbr to be installed
at all. You would need pbr on machine building package
but not on machines that install the package.

Stolen from Swift:
https://github.com/openstack/swift/blob/master/swift/__init__.py

Change-Id: Ic3a8fe1d9fe8d7d1f84b63142049970295fbcaab
2015-12-15 12:06:29 +01:00
Ondřej Nový b7255c2b63 Support for Swift older than Juno dropped
Change-Id: Ia6540884430eba17b62018ba73fbde541bb0566b
2015-12-13 20:59:10 +01:00
Ondřej Nový 9d96d14d83 Unit tests for swift_version
Return False if version can't be compared. It's safer.

Change-Id: I1af9f15712ae7c27979ab4a78f7dd8a6fc43057e
2015-12-13 18:10:17 +01:00
Peter Lisák f5f3d7e72b use standard library json instead of simplejson
Based on https://review.openstack.org/#/c/240596/

Change-Id: I7f5be799ea7dcb49b7d9df830f1f15ee9a02b3ca
2015-11-23 12:13:07 +01:00
Ondřej Nový 79c153f7b1 Remove 60 secs subtraction from item_expires
According to https://github.com/gholt/swauth/issues/73 nobody
knows why is this here. Let's try to remove it :).

Change-Id: I6de2c7eca5b7c4cbed61c966149055705efe8323
2015-11-17 12:38:20 +01:00
Ondřej Nový fca1400e40 Use ValueError instead of Exception when appropriate
Change-Id: I7f9f72b4efcca01170b7e311057e4ed6bae73179
2015-11-15 22:34:27 +01:00
Ondřej Nový b7e965c99f PEP8 fixies
Change-Id: I651729a368a9a804ad4431938ff70ddf0303a7c8
2015-11-15 17:16:09 +01:00
Peter Lisák 69cadf8499 tox.ini and unittest fix
Change-Id: Ic6b2435159c63adc81b8881a7a0c1e65a14f7c1c
2015-11-13 09:57:19 +01:00
onovy b31b308728 Cleanup. 2015-04-28 09:40:02 +02:00
onovy e14a7b3df8 Security fixies.
Generate new salt for every password.
Support different salt for passwords.
Support SHA512 for hashing.
2015-04-21 11:26:09 +02:00
onovy 04e55d8ec3 When creating account create account in Swift first.
When you try to create account with same suffix as already existed
before, Swift raises error. But SwAuth already created container for
this account in .auth which creates inconsistency.
2015-04-17 13:09:13 +02:00
Christopher Bartz 0a6bdddf21 Using keystone at same time. 2014-12-18 12:56:25 +01:00
gholt 11aa56cc08 Fixes #66 RedHat version parsing issue 2014-06-17 13:35:31 +00:00
Prashanth Pai a92d6f13f7 Add support for storage policy
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2014-03-12 12:52:03 +05:30
Greg Holt 3885d8bfab Updated code comment 2014-03-02 03:51:56 +00:00
Thiago da Silva 701a331875 Fix bug where admin is able to delete reseller_admin
Changed the code to only allow the super_admin to delete a reseller_admin.
This follows the same logic of user creation, where only the super_admin
can create a reseller_admin.

Also, took the opportunity to refactor some code and implemented
get_user_detail method to remove duplicated code

Signed-off-by: Thiago da Silva <thiago@redhat.com>
2014-02-27 15:06:18 -05:00
Greg Holt 4e97d00df4 Merge pull request #61 from prashanthpai/update-password
Allow users to change their own password/key
2014-01-24 13:04:06 -08:00
Greg Holt f20e2f047d Merge pull request #56 from leoh0/master
Remove old token in memcache when token needs to be updated
2014-01-24 12:55:18 -08:00
Prashanth Pai c2bb81a60e Allow users to change their own password/key
Users were not able to update their own password/key
with the update operation resulting in 403 (HTTPForbidden).

EXAMPLES:
Command to update password/key of regular user:
gswauth-add-user -U account1:user1 -K old_pass account1 user1 new_pass

Command to update password/key of account admin:
gswauth-add-user -U account1:admin -K old_pass -a account1 admin new_pass

Command to update password/key of reseller_admin:
gswauth-add-user -U account1:radmin -K old_pass -r account1 radmin new_pass

Signed-off-by: Prashanth Pai <ppai@redhat.com>
2014-01-20 10:29:24 +05:30
Prashanth Pai ff5369b7ae Distinguish between 401(Unauthorized) and 403(Forbidden)
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2013-12-10 13:04:10 +05:30
Eohyung Lee 17faf4e54f Remove old token in memcache when token needs to be updated 2013-10-17 13:18:11 +09:00
gholt cbe34c622f Moving to work-in-progress 1.0.9-dev 2013-04-24 07:50:33 +00:00
gholt 4fc009d5ad Releasing 1.0.8 2013-04-24 07:47:25 +00:00
gholt c44b5b6448 Fixed to work with newer Swift 2013-04-24 07:32:32 +00:00
Christian Schwede e94aeb7f1c Add request.environ[reseller_request] = True 2013-03-08 23:31:49 +01:00
gholt 344ceb4b6d Moving to work-in-progress 1.0.8-dev 2013-03-05 19:03:45 +00:00
gholt 80cec7a7fd Releasing 1.0.7 2013-03-05 18:56:02 +00:00
gholt 36a156bc52 Allow user set X-Auth-Token-Lifetime, with limits
* New conf value of max_token_life, existing token_life conf value is
  now just the default token life.

* When a user requests a token, they can send an
  X-Auth-Token-Lifetime header with the number of seconds they'd like
  the token to be valid for. This will be capped to max_token_life.

* Response to getting a token has new X-Auth-Token-Expires header
  that is the number of seconds the token is valid for.
2013-03-01 06:35:51 +00:00
Christian Schwede ce1072bc97 Add X-Auth-Token-Lifetime and user_set_tokenlifetime option 2013-02-15 17:07:03 +01:00