merged trunk
This commit is contained in:
@@ -24,7 +24,6 @@ import logging
|
||||
import os
|
||||
import shutil
|
||||
import string
|
||||
import sys
|
||||
import tempfile
|
||||
import uuid
|
||||
import zipfile
|
||||
@@ -325,8 +324,7 @@ class AuthManager(object):
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""Returns the AuthManager singleton"""
|
||||
if not cls._instance:
|
||||
cls._instance = super(AuthManager, cls).__new__(
|
||||
cls, *args, **kwargs)
|
||||
cls._instance = super(AuthManager, cls).__new__(cls)
|
||||
return cls._instance
|
||||
|
||||
def __init__(self, driver=None, *args, **kwargs):
|
||||
@@ -419,6 +417,12 @@ class AuthManager(object):
|
||||
raise exception.NotAuthorized('Signature does not match')
|
||||
return (user, project)
|
||||
|
||||
def get_access_key(self, user, project):
|
||||
"""Get an access key that includes user and project"""
|
||||
if not isinstance(user, User):
|
||||
user = self.get_user(user)
|
||||
return "%s:%s" % (user.access, Project.safe_id(project))
|
||||
|
||||
def is_superuser(self, user):
|
||||
"""Checks for superuser status, allowing user to bypass rbac
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import urllib
|
||||
|
||||
from nova import flags
|
||||
from nova import utils
|
||||
from nova.auth import manager
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
@@ -75,13 +76,16 @@ def deregister(context, image_id):
|
||||
query_args=qs({'image_id': image_id}))
|
||||
|
||||
def conn(context):
|
||||
return boto.s3.connection.S3Connection (
|
||||
aws_access_key_id=str('%s:%s' % (context.user.access, context.project.name)),
|
||||
aws_secret_access_key=str(context.user.secret),
|
||||
is_secure=False,
|
||||
calling_format=boto.s3.connection.OrdinaryCallingFormat(),
|
||||
port=FLAGS.s3_port,
|
||||
host=FLAGS.s3_host)
|
||||
access = manager.AuthManager().get_access_key(context.user,
|
||||
context.project)
|
||||
secret = str(context.user.secret)
|
||||
calling = boto.s3.connection.OrdinaryCallingFormat()
|
||||
return boto.s3.connection.S3Connection(aws_access_key_id=access,
|
||||
aws_secret_access_key=secret,
|
||||
is_secure=False,
|
||||
calling_format=calling,
|
||||
port=FLAGS.s3_port,
|
||||
host=FLAGS.s3_host)
|
||||
|
||||
|
||||
def qs(params):
|
||||
|
||||
Reference in New Issue
Block a user