Skip to content

Commit

Permalink
rgw: Rework of s3 LDAP Authentication code.
Browse files Browse the repository at this point in the history
The LDAP authentication code has been reworked based
on the new authentication infrastructure.

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
  • Loading branch information
pritha-srivastava committed Jul 26, 2016
1 parent f8ecf53 commit 1229058
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 141 deletions.
5 changes: 5 additions & 0 deletions src/rgw/rgw_auth.cc
Expand Up @@ -149,6 +149,11 @@ void RGWRemoteAuthApplier::create_account(const rgw_user& acct_user,
{
rgw_user new_acct_user = acct_user;

if (info.acct_type) {
//ldap/keystone for s3 users
user_info.type = info.acct_type;
}

/* Administrator may enforce creating new accounts within their own tenants.
* The config parameter name is kept due to legacy. */
if (new_acct_user.tenant.empty() && g_conf->rgw_keystone_implicit_tenants) {
Expand Down
7 changes: 5 additions & 2 deletions src/rgw/rgw_auth.h
Expand Up @@ -117,16 +117,19 @@ class RGWRemoteAuthApplier : public RGWAuthApplier {
const std::string acct_name;
const uint32_t perm_mask;
const bool is_admin;
const uint32_t acct_type;

public:
AuthInfo(const rgw_user& acct_user,
const std::string& acct_name,
const uint32_t perm_mask,
const bool is_admin)
const bool is_admin,
const uint32_t acct_type=0)
: acct_user(acct_user),
acct_name(acct_name),
perm_mask(perm_mask),
is_admin(is_admin) {
is_admin(is_admin),
acct_type(acct_type) {
}
};

Expand Down
24 changes: 19 additions & 5 deletions src/rgw/rgw_common.h
Expand Up @@ -527,6 +527,14 @@ void encode_json(const char *name, const RGWUserCaps& val, Formatter *f);

void decode_json_obj(obj_version& v, JSONObj *obj);

enum RGWUserSourceType
{
TYPE_NONE=0,
TYPE_RGW=1,
TYPE_KEYSTONE=2,
TYPE_LDAP=3
};

struct RGWUserInfo
{
uint64_t auid;
Expand All @@ -547,14 +555,16 @@ struct RGWUserInfo
RGWQuotaInfo bucket_quota;
map<int, string> temp_url_keys;
RGWQuotaInfo user_quota;
uint32_t type;

RGWUserInfo()
: auid(0),
suspended(0),
max_buckets(RGW_DEFAULT_MAX_BUCKETS),
op_mask(RGW_OP_TYPE_ALL),
admin(0),
system(0) {
system(0),
type(TYPE_NONE) {
}

RGWAccessKey* get_key0() {
Expand All @@ -565,7 +575,7 @@ struct RGWUserInfo
}

void encode(bufferlist& bl) const {
ENCODE_START(18, 9, bl);
ENCODE_START(19, 9, bl);
::encode(auid, bl);
string access_key;
string secret_key;
Expand Down Expand Up @@ -605,10 +615,11 @@ struct RGWUserInfo
::encode(user_quota, bl);
::encode(user_id.tenant, bl);
::encode(admin, bl);
::encode(type, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN_32(18, 9, 9, bl);
DECODE_START_LEGACY_COMPAT_LEN_32(19, 9, 9, bl);
if (struct_v >= 2) ::decode(auid, bl);
else auid = CEPH_AUTH_UID_DEFAULT;
string access_key;
Expand Down Expand Up @@ -678,6 +689,9 @@ struct RGWUserInfo
if (struct_v >= 18) {
::decode(admin, bl);
}
if (struct_v >= 19) {
::decode(type, bl);
}
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
Expand Down Expand Up @@ -727,7 +741,7 @@ struct rgw_bucket {
}

void encode(bufferlist& bl) const {
ENCODE_START(8, 3, bl);
ENCODE_START(9, 3, bl);
::encode(name, bl);
::encode(data_pool, bl);
::encode(marker, bl);
Expand All @@ -738,7 +752,7 @@ struct rgw_bucket {
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl);
DECODE_START_LEGACY_COMPAT_LEN(9, 3, 3, bl);
::decode(name, bl);
::decode(data_pool, bl);
if (struct_v >= 2) {
Expand Down
2 changes: 2 additions & 0 deletions src/rgw/rgw_json_enc.cc
Expand Up @@ -427,6 +427,7 @@ void RGWUserInfo::dump(Formatter *f) const
encode_json("bucket_quota", bucket_quota, f);
encode_json("user_quota", user_quota, f);
encode_json("temp_url_keys", temp_url_keys, f);
encode_json("type", type, f);
}


Expand Down Expand Up @@ -484,6 +485,7 @@ void RGWUserInfo::decode_json(JSONObj *obj)
JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
JSONDecoder::decode_json("user_quota", user_quota, obj);
JSONDecoder::decode_json("temp_url_keys", temp_url_keys, obj);
JSONDecoder::decode_json("type", type, obj);
}

void RGWQuotaInfo::dump(Formatter *f) const
Expand Down

0 comments on commit 1229058

Please sign in to comment.