Permalink
Browse files

First edition of the webadmin

  • Loading branch information...
1 parent 049e885 commit e5c8879ea7b2f5e9651fe97bf151ed35750b95c8 @gholt committed Jun 27, 2011
Showing with 609 additions and 16 deletions.
  1. +19 −5 README
  2. +18 −5 doc/source/index.rst
  3. +20 −6 swauth/middleware.py
  4. +552 −0 webadmin/index.html
View
24 README
@@ -38,12 +38,26 @@ Quick Install
set log_name = swauth
super_admin_key = swauthkey
-4) Restart your proxy server ``swift-init proxy reload``.
+4) Restart your proxy server ``swift-init proxy reload``
-5) Initialize the Swauth backing store in Swift ``swauth-prep -K swauthkey``.
+5) Initialize the Swauth backing store in Swift ``swauth-prep -K swauthkey``
6) Add an account/user ``swauth-add-user -A http://127.0.0.1:8080/auth/ -K
- swauthkey -a test tester testing``.
+ swauthkey -a test tester testing``
-7) Ensure it works ``st -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K
- testing stat -v``.
+7) Ensure it works ``swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K
+ testing stat -v``
+
+
+Web Admin Install
+-----------------
+
+1) If you installed from packages, you'll need to cd to the webadmin directory
+ the package installed. This is ``/usr/share/doc/python-swauth/webadmin``
+ with the Lucid packages. If you installed from source, you'll need to cd to
+ the webadmin directory in the source directory.
+
+2) Upload the Web Admin files with ``swift -A http://127.0.0.1:8080/auth/v1.0
+ -U .super_admin:.super_admin -K swauthkey upload .webadmin .``
+
+3) Open ``http://127.0.0.1:8080/auth/`` in your browser.
View
@@ -45,15 +45,28 @@ Quick Install
set log_name = swauth
super_admin_key = swauthkey
-4) Restart your proxy server ``swift-init proxy reload``.
+4) Restart your proxy server ``swift-init proxy reload``
-5) Initialize the Swauth backing store in Swift ``swauth-prep -K swauthkey``.
+5) Initialize the Swauth backing store in Swift ``swauth-prep -K swauthkey``
6) Add an account/user ``swauth-add-user -A http://127.0.0.1:8080/auth/ -K
- swauthkey -a test tester testing``.
+ swauthkey -a test tester testing``
-7) Ensure it works ``st -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K
- testing stat -v``.
+7) Ensure it works ``swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K
+ testing stat -v``
+
+Web Admin Install
+-----------------
+
+1) If you installed from packages, you'll need to cd to the webadmin directory
+ the package installed. This is ``/usr/share/doc/python-swauth/webadmin``
+ with the Lucid packages. If you installed from source, you'll need to cd to
+ the webadmin directory in the source directory.
+
+2) Upload the Web Admin files with ``swift -A http://127.0.0.1:8080/auth/v1.0
+ -U .super_admin:.super_admin -K swauthkey upload .webadmin .``
+
+3) Open ``http://127.0.0.1:8080/auth/`` in your browser.
Contents
--------
View
@@ -30,8 +30,8 @@
from eventlet import TimeoutError
from webob import Response, Request
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
- HTTPCreated, HTTPForbidden, HTTPNoContent, HTTPNotFound, \
- HTTPServiceUnavailable, HTTPUnauthorized
+ HTTPCreated, HTTPForbidden, HTTPMethodNotAllowed, HTTPMovedPermanently, \
+ HTTPNoContent, HTTPNotFound, HTTPServiceUnavailable, HTTPUnauthorized
from swift.common.bufferedhttp import http_connect_raw as http_connect
from swift.common.middleware.acl import clean_acl, parse_acl, referrer_allowed
@@ -167,9 +167,12 @@ def __call__(self, env, start_response):
"""
if 'HTTP_X_CF_TRANS_ID' not in env:
env['HTTP_X_CF_TRANS_ID'] = 'tx' + str(uuid4())
- if not self.swauth_remote and \
- env.get('PATH_INFO', '').startswith(self.auth_prefix):
- return self.handle(env, start_response)
+ if not self.swauth_remote:
+ if env.get('PATH_INFO', '') == self.auth_prefix[:-1]:
+ return HTTPMovedPermanently(add_slash=True)(env,
+ start_response)
+ elif env.get('PATH_INFO', '').startswith(self.auth_prefix):
+ return self.handle(env, start_response)
s3 = env.get('HTTP_AUTHORIZATION')
token = env.get('HTTP_X_AUTH_TOKEN', env.get('HTTP_X_STORAGE_TOKEN'))
if s3 or (token and token.startswith(self.reseller_prefix)):
@@ -424,7 +427,7 @@ def handle_request(self, req):
handler = None
try:
version, account, user, _junk = split_path(req.path_info,
- minsegs=1, maxsegs=4, rest_with_last=True)
+ minsegs=0, maxsegs=4, rest_with_last=True)
except ValueError:
return HTTPNotFound(request=req)
if version in ('v1', 'v1.0', 'auth'):
@@ -460,12 +463,23 @@ def handle_request(self, req):
handler = self.handle_prep
elif user == '.services':
handler = self.handle_set_services
+ else:
+ handler = self.handle_webadmin
if not handler:
req.response = HTTPBadRequest(request=req)
else:
req.response = handler(req)
return req.response
+ def handle_webadmin(self, req):
+ if req.method not in ('GET', 'HEAD'):
+ return HTTPMethodNotAllowed(request=req)
+ subpath = req.path[len(self.auth_prefix):] or 'index.html'
+ path = quote('/v1/%s/.webadmin/%s' % (self.auth_account, subpath))
+ req.response = self.make_request(req.environ, req.method,
+ path).get_response(self.app)
+ return req.response
+
def handle_prep(self, req):
"""
Handles the POST v2/.prep call for preparing the backing store Swift
Oops, something went wrong.

0 comments on commit e5c8879

Please sign in to comment.