1
#ifndef CEPH_RGW_USER_H
2
#define CEPH_RGW_USER_H
6
#include "include/types.h"
7
#include "rgw_common.h"
11
#define USER_INFO_BUCKET_NAME ".users"
12
#define USER_INFO_EMAIL_BUCKET_NAME ".users.email"
13
#define RGW_USER_ANON_ID "anonymous"
16
* A string wrapper that includes encode/decode functions
17
* for easily accessing a UID in all forms
22
void encode(bufferlist& bl) const {
23
::encode(user_id, bl);
25
void decode(bufferlist::iterator& bl) {
26
::decode(user_id, bl);
29
WRITE_CLASS_ENCODER(RGWUID)
32
* Get the info for a user out of storage.
33
* Returns: 0 on success, -ERR# on failure
35
extern int rgw_get_user_info(string user_id, RGWUserInfo& info);
37
* Get the anonymous (ie, unauthenticated) user info.
39
extern void rgw_get_anon_user(RGWUserInfo& info);
41
* Save the given user information to storage.
42
* Returns: 0 on success, -ERR# on failure.
44
extern int rgw_store_user_info(RGWUserInfo& info);
46
* Given an email, finds the user_id associated with it.
47
* returns: 0 on success, -ERR# on failure (including nonexistence)
49
extern int rgw_get_uid_by_email(string& email, string& user_id);
51
* Given an RGWUserInfo, deletes the user and its bucket ACLs.
53
extern int rgw_delete_user(RGWUserInfo& user);
55
* Store a list of the user's buckets, with associated functinos.
59
map<string, RGWObjEnt> buckets;
63
void encode(bufferlist& bl) const {
64
::encode(buckets, bl);
66
void decode(bufferlist::iterator& bl) {
67
::decode(buckets, bl);
70
* Check if the user owns a bucket by the given name.
72
bool owns(string& name) {
73
map<string, RGWObjEnt>::iterator iter;
74
iter = buckets.find(name);
75
return (iter != buckets.end());
79
* Add a (created) bucket to the user's bucket list.
81
void add(RGWObjEnt& bucket) {
82
buckets[bucket.name] = bucket;
86
* Remove a bucket from the user's list by name.
88
void remove(string& name) {
89
map<string, RGWObjEnt>::iterator iter;
90
iter = buckets.find(name);
91
if (iter != buckets.end()) {
97
* Get the user's buckets as a map.
99
map<string, RGWObjEnt>& get_buckets() { return buckets; }
101
WRITE_CLASS_ENCODER(RGWUserBuckets)
104
* Get all the buckets owned by a user and fill up an RGWUserBuckets with them.
105
* Returns: 0 on success, -ERR# on failure.
107
extern int rgw_get_user_buckets(string user_id, RGWUserBuckets& buckets);
109
* Store the set of buckets associated with a user.
110
* This completely overwrites any previously-stored list, so be careful!
111
* Returns 0 on success, -ERR# otherwise.
113
extern int rgw_put_user_buckets(string user_id, RGWUserBuckets& buckets);