From f9443865ba7e3deb4621088dab83ed0962fae4a5 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 31 Oct 2012 11:23:28 -0700 Subject: rgw: map keystone tenant id to rgw user Instead of mapping the tenant name. Keep the name as the display_name. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_swift.cc | 12 ++++++++++-- src/rgw/rgw_swift.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc index 14c0b958e72..19dbe1a340e 100644 --- a/src/rgw/rgw_swift.cc +++ b/src/rgw/rgw_swift.cc @@ -101,6 +101,7 @@ public: class KeystoneTokenResponseParser { public: string tenant_name; + string tenant_id; string user_name; string expires; @@ -172,6 +173,12 @@ int KeystoneTokenResponseParser::parse(bufferlist& bl) return -EINVAL; } + if (!tenant->get_data("id", &tenant_id)) { + dout(0) << "tenant is missing id field" << dendl; + return -EINVAL; + } + + if (!tenant->get_data("name", &tenant_name)) { dout(0) << "tenant is missing name field" << dendl; return -EINVAL; @@ -215,7 +222,8 @@ static int rgw_parse_keystone_token_response(bufferlist& bl, struct rgw_swift_au dout(0) << "validated token: " << p.tenant_name << ":" << p.user_name << " expires: " << p.expires << dendl; - info->user = p.tenant_name; + info->user = p.tenant_id; + info->display_name = p.tenant_name; info->status = 200; return 0; @@ -248,7 +256,7 @@ static int rgw_swift_validate_keystone_token(RGWRados *store, const char *token, if (rgw_get_user_info_by_uid(store, info->user, rgw_user) < 0) { dout(0) << "NOTICE: couldn't map swift user" << dendl; rgw_user.user_id = info->user; - rgw_user.display_name = info->user; /* no display name available */ + rgw_user.display_name = info->display_name; ret = rgw_store_user_info(store, rgw_user, true); if (ret < 0) { diff --git a/src/rgw/rgw_swift.h b/src/rgw/rgw_swift.h index 9cc289e1c34..f8a64d34460 100644 --- a/src/rgw/rgw_swift.h +++ b/src/rgw/rgw_swift.h @@ -10,6 +10,7 @@ struct rgw_swift_auth_info { int status; string auth_groups; string user; + string display_name; long long ttl; rgw_swift_auth_info() : status(0), ttl(0) {} -- cgit v1.2.1