Skip to content

Commit

Permalink
Merge pull request #10307 from pritha-srivastava/wip_s3_auth_rework
Browse files Browse the repository at this point in the history
rgw: Rework of s3 LDAP Authentication code.

verified: MS AD
  • Loading branch information
mattbenjamin committed Aug 3, 2016
2 parents c162a8a + bcdc2df commit f62f7ab
Show file tree
Hide file tree
Showing 7 changed files with 257 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=TYPE_NONE)
: 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 @@ -530,6 +530,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 @@ -550,14 +558,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 @@ -568,7 +578,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 @@ -608,10 +618,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 @@ -681,6 +692,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 @@ -730,7 +744,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 @@ -741,7 +755,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
32 changes: 32 additions & 0 deletions src/rgw/rgw_json_enc.cc
Expand Up @@ -427,6 +427,26 @@ 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);

string user_source_type;
switch ((RGWUserSourceType)type) {
case TYPE_RGW:
user_source_type = "rgw";
break;
case TYPE_KEYSTONE:
user_source_type = "keystone";
break;
case TYPE_LDAP:
user_source_type = "ldap";
break;
case TYPE_NONE:
user_source_type = "none";
break;
default:
user_source_type = "none";
break;
}
encode_json("type", user_source_type, f);
}


Expand Down Expand Up @@ -484,6 +504,18 @@ 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);

string user_source_type;
JSONDecoder::decode_json("type", user_source_type, obj);
if (user_source_type == "rgw") {
type = TYPE_RGW;
} else if (user_source_type == "keystone") {
type = TYPE_KEYSTONE;
} else if (user_source_type == "ldap") {
type = TYPE_LDAP;
} else if (user_source_type == "none") {
type = TYPE_NONE;
}
}

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

0 comments on commit f62f7ab

Please sign in to comment.