if (ret < 0) {
if (s->system_request) {
dout(2) << "overriding permissions due to system operation" << dendl;
- } else if (s->auth_identity->is_admin_of(s->user->user_id)) {
+ } else if (s->auth.identity->is_admin_of(s->user->user_id)) {
dout(2) << "overriding permissions due to admin operation" << dendl;
} else {
abort_req(s, op, ret);
if (ret < 0) {
if (s->system_request) {
dout(2) << "overriding permissions due to system operation" << dendl;
- } else if (s->auth_identity->is_admin_of(s->user->user_id)) {
+ } else if (s->auth.identity->is_admin_of(s->user->user_id)) {
dout(2) << "overriding permissions due to admin operation" << dendl;
} else {
abort_req(s, op, ret);
_add_grant(grant);
}
-uint32_t RGWAccessControlList::get_perm(const RGWIdentityApplier& auth_identity,
+uint32_t RGWAccessControlList::get_perm(const rgw::auth::Identity& auth_identity,
const uint32_t perm_mask)
{
ldout(cct, 5) << "Searching permissions for identity=" << auth_identity
}
}
-uint32_t RGWAccessControlPolicy::get_perm(const RGWIdentityApplier& auth_identity,
+uint32_t RGWAccessControlPolicy::get_perm(const rgw::auth::Identity& auth_identity,
const uint32_t perm_mask,
const char * const http_referer)
{
return perm;
}
-bool RGWAccessControlPolicy::verify_permission(const RGWIdentityApplier& auth_identity,
+bool RGWAccessControlPolicy::verify_permission(const rgw::auth::Identity& auth_identity,
const uint32_t user_perm_mask,
const uint32_t perm,
const char * const http_referer)
};
WRITE_CLASS_ENCODER(ACLReferer)
-class RGWIdentityApplier;
+namespace rgw {
+namespace auth {
+ class Identity;
+}
+}
class RGWAccessControlList
{
virtual ~RGWAccessControlList() {}
- uint32_t get_perm(const RGWIdentityApplier& auth_identity,
+ uint32_t get_perm(const rgw::auth::Identity& auth_identity,
uint32_t perm_mask);
uint32_t get_group_perm(ACLGroupTypeEnum group, uint32_t perm_mask);
uint32_t get_referer_perm(const std::string http_referer, uint32_t perm_mask);
acl.set_ctx(ctx);
}
- uint32_t get_perm(const RGWIdentityApplier& auth_identity,
+ uint32_t get_perm(const rgw::auth::Identity& auth_identity,
uint32_t perm_mask,
const char * http_referer);
uint32_t get_group_perm(ACLGroupTypeEnum group, uint32_t perm_mask);
- bool verify_permission(const RGWIdentityApplier& auth_identity,
+ bool verify_permission(const rgw::auth::Identity& auth_identity,
uint32_t user_perm_mask,
uint32_t perm,
const char * http_referer = nullptr);
if ((perm & (int)s->perm_mask) != perm)
return false;
- return user_acl->verify_permission(*s->auth_identity, perm, perm);
+ return user_acl->verify_permission(*s->auth.identity, perm, perm);
}
bool verify_user_permission(struct req_state * const s,
if (!s->bucket_info.requester_pays)
return true;
- if (s->auth_identity->is_owner_of(s->bucket_info.owner))
+ if (s->auth.identity->is_owner_of(s->bucket_info.owner))
return true;
- if (s->auth_identity->is_anonymous()) {
+ if (s->auth.identity->is_anonymous()) {
return false;
}
if (!verify_requester_payer_permission(s))
return false;
- if (bucket_acl->verify_permission(*s->auth_identity, perm, perm,
+ if (bucket_acl->verify_permission(*s->auth.identity, perm, perm,
s->info.env->get("HTTP_REFERER")))
return true;
if (!user_acl)
return false;
- return user_acl->verify_permission(*s->auth_identity, perm, perm);
+ return user_acl->verify_permission(*s->auth.identity, perm, perm);
}
bool verify_bucket_permission(struct req_state * const s, const int perm)
return false;
}
- bool ret = object_acl->verify_permission(*s->auth_identity, s->perm_mask, perm);
+ bool ret = object_acl->verify_permission(*s->auth.identity, s->perm_mask, perm);
if (ret) {
return true;
}
/* we already verified the user mask above, so we pass swift_perm as the mask here,
otherwise the mask might not cover the swift permissions bits */
- if (bucket_acl->verify_permission(*s->auth_identity, swift_perm, swift_perm,
+ if (bucket_acl->verify_permission(*s->auth.identity, swift_perm, swift_perm,
s->info.env->get("HTTP_REFERER")))
return true;
if (!user_acl)
return false;
- return user_acl->verify_permission(*s->auth_identity, swift_perm, swift_perm);
+ return user_acl->verify_permission(*s->auth.identity, swift_perm, swift_perm);
}
bool verify_object_permission(struct req_state *s, int perm)
RGWUserInfo *user;
- /* Object having the knowledge about an authenticated identity and allowing
- * to apply it during the authorization phase (verify_permission() methods
- * of a given RGWOp). Thus, it bounds authentication and authorization steps
- * through a well-defined interface. For more details, see rgw_auth.h. */
- std::unique_ptr<RGWIdentityApplier> auth_identity;
struct {
- /* TODO(rzarzynski): switch out to the static_ptr. */
+ /* TODO(rzarzynski): switch out to the static_ptr for both members. */
+
+ /* Object having the knowledge about an authenticated identity and allowing
+ * to apply it during the authorization phase (verify_permission() methods
+ * of a given RGWOp). Thus, it bounds authentication and authorization steps
+ * through a well-defined interface. For more details, see rgw_auth.h. */
std::unique_ptr<rgw::auth::Identity> identity;
+
std::unique_ptr<rgw::auth::Completer> completer;
} auth;
const rgw_user& bucket_owner = bucket_policy.get_owner().get_id();
if (bucket_owner.compare(s->user->user_id) != 0 &&
- !s->auth_identity->is_admin_of(bucket_owner) &&
- !bucket_policy.verify_permission(*s->auth_identity, s->perm_mask,
- RGW_PERM_READ)) {
+ ! s->auth.identity->is_admin_of(bucket_owner) &&
+ ! bucket_policy.verify_permission(*s->auth.identity, s->perm_mask,
+ RGW_PERM_READ)) {
ret = -EACCES;
} else {
ret = -ENOENT;
int RGWGetUsage::verify_permission()
{
- if (s->auth_identity->is_anonymous()) {
+ if (s->auth.identity->is_anonymous()) {
return -EACCES;
}
int RGWGetBucketVersioning::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
int RGWSetBucketVersioning::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
int RGWGetBucketLogging::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
int RGWGetBucketLocation::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
/* This check is mostly needed for S3 that doesn't support account ACL.
* Swift doesn't allow to delegate any permission to an anonymous user,
* so it will become an early exit in such case. */
- if (s->auth_identity->is_anonymous()) {
+ if (s->auth.identity->is_anonymous()) {
return -EACCES;
}
}
/* admin request overrides permission checks */
- if (!s->auth_identity->is_admin_of(cs_policy.get_owner().get_id()) &&
- !cs_policy.verify_permission(*s->auth_identity, s->perm_mask, RGW_PERM_READ)) {
+ if (! s->auth.identity->is_admin_of(cs_policy.get_owner().get_id()) &&
+ ! cs_policy.verify_permission(*s->auth.identity, s->perm_mask, RGW_PERM_READ)) {
return -EACCES;
}
int RGWPutMetadataAccount::verify_permission()
{
- if (s->auth_identity->is_anonymous()) {
+ if (s->auth.identity->is_anonymous()) {
return -EACCES;
}
}
/* admin request overrides permission checks */
- if (!s->auth_identity->is_admin_of(src_policy.get_owner().get_id()) &&
- !src_policy.verify_permission(*s->auth_identity, s->perm_mask,
- RGW_PERM_READ)) {
+ if (! s->auth.identity->is_admin_of(src_policy.get_owner().get_id()) &&
+ ! src_policy.verify_permission(*s->auth.identity, s->perm_mask,
+ RGW_PERM_READ)) {
return -EACCES;
}
}
}
/* admin request overrides permission checks */
- if (!s->auth_identity->is_admin_of(dest_policy.get_owner().get_id()) &&
- !dest_bucket_policy.verify_permission(*s->auth_identity, s->perm_mask,
- RGW_PERM_WRITE)) {
+ if (! s->auth.identity->is_admin_of(dest_policy.get_owner().get_id()) &&
+ ! dest_bucket_policy.verify_permission(*s->auth.identity, s->perm_mask,
+ RGW_PERM_WRITE)) {
return -EACCES;
}
int RGWGetCORS::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
int RGWPutCORS::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
int RGWDeleteCORS::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
int RGWSetRequestPayment::verify_permission()
{
- if (false == s->auth_identity->is_owner_of(s->bucket_owner.get_id())) {
+ if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
return -EACCES;
}
if (ret < 0) {
if (s->system_request) {
dout(2) << "overriding permissions due to system operation" << dendl;
- } else if (s->auth_identity->is_admin_of(s->user->user_id)) {
+ } else if (s->auth.identity->is_admin_of(s->user->user_id)) {
dout(2) << "overriding permissions due to admin operation" << dendl;
} else {
return ret;
int RGWRoleRead::verify_permission()
{
- if (s->auth_identity->is_anonymous()) {
+ if (s->auth.identity->is_anonymous()) {
return -EACCES;
}
int RGWRoleWrite::verify_permission()
{
- if (s->auth_identity->is_anonymous()) {
+ if (s->auth.identity->is_anonymous()) {
return -EACCES;
}
/* We have to differentiate error codes depending on whether user is
* anonymous (401 Unauthorized) or he doesn't have necessary permissions
* (403 Forbidden). */
- if (s->auth_identity->is_anonymous() && op_ret == -EACCES) {
+ if (s->auth.identity->is_anonymous() && op_ret == -EACCES) {
return -EPERM;
} else {
return op_ret;
/* We have to differentiate error codes depending on whether user is
* anonymous (401 Unauthorized) or he doesn't have necessary permissions
* (403 Forbidden). */
- if (s->auth_identity->is_anonymous() && op_ret == -EACCES) {
+ if (s->auth.identity->is_anonymous() && op_ret == -EACCES) {
return -EPERM;
} else {
return op_ret;
/* We have to differentiate error codes depending on whether user is
* anonymous (401 Unauthorized) or he doesn't have necessary permissions
* (403 Forbidden). */
- if (s->auth_identity->is_anonymous() && op_ret == -EACCES) {
+ if (s->auth.identity->is_anonymous() && op_ret == -EACCES) {
return -EPERM;
} else {
return op_ret;
}
/* We also need to handle early failures from the auth system. In such cases
- * req_state::auth_identity may be empty. Let's treat that the same way as
+ * req_state::auth.identity may be empty. Let's treat that the same way as
* the anonymous access. */
- if (! s->auth_identity) {
+ if (! s->auth.identity) {
return true;
}
/* Swift serves websites only for anonymous requests unless client explicitly
* requested this behaviour by supplying X-Web-Mode HTTP header set to true. */
- if (s->auth_identity->is_anonymous() || is_web_mode()) {
+ if (s->auth.identity->is_anonymous() || is_web_mode()) {
return true;
}