~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to nova/api/auth.py

Remove keystone middlewares.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    def __call__(self, req):
44
44
        req.environ['nova.context'] = self.context
45
45
        return self.application
46
 
 
47
 
 
48
 
class KeystoneContext(wsgi.Middleware):
49
 
    """Make a request context from keystone headers"""
50
 
 
51
 
    @webob.dec.wsgify(RequestClass=wsgi.Request)
52
 
    def __call__(self, req):
53
 
        try:
54
 
            user_id = req.headers['X_USER']
55
 
        except KeyError:
56
 
            return webob.exc.HTTPUnauthorized()
57
 
        # get the roles
58
 
        roles = [r.strip() for r in req.headers.get('X_ROLE', '').split(',')]
59
 
        project_id = req.headers['X_TENANT']
60
 
        # Get the auth token
61
 
        auth_token = req.headers.get('X_AUTH_TOKEN',
62
 
                                     req.headers.get('X_STORAGE_TOKEN'))
63
 
 
64
 
        # Build a context, including the auth_token...
65
 
        remote_address = getattr(req, 'remote_address', '127.0.0.1')
66
 
        remote_address = req.remote_addr
67
 
        if FLAGS.use_forwarded_for:
68
 
            remote_address = req.headers.get('X-Forwarded-For', remote_address)
69
 
        ctx = context.RequestContext(user_id,
70
 
                                     project_id,
71
 
                                     roles=roles,
72
 
                                     auth_token=auth_token,
73
 
                                     strategy='keystone',
74
 
                                     remote_address=remote_address)
75
 
 
76
 
        req.environ['nova.context'] = ctx
77
 
        return self.application