Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGW Bucket Policies #14307

Merged
merged 11 commits into from
May 17, 2017
Merged

RGW Bucket Policies #14307

merged 11 commits into from
May 17, 2017

Conversation

adamemerson
Copy link
Contributor

It is by these words— no not the ones you're reading, but the ones in your policy document. it is by those very words that your buckets shall be guarded and gazed, watched and warded. They shall speak and grant access to some and turn others away in despair.

@mattbenjamin mattbenjamin changed the title DNM: Bucket Policies DNM: RGW Bucket Policies Apr 4, 2017
@mattbenjamin mattbenjamin self-assigned this Apr 4, 2017
Configuration
=============

Bucket poliies are managed through standard S3 operations rather than
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

policies

@@ -3314,6 +3431,9 @@ void RGWPutObj::execute()

int RGWPostObj::verify_permission()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's strange...

if (s->iam_policy->eval(s->env, *s->auth.identity,
s->object.instance.empty() ?
rgw::IAM::s3ListBucket :
rgw::IAM::s3ListBucketVersions,
Copy link
Contributor

@cbodley cbodley Apr 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check should be based on the RGWListBucket::list_versions flag. the only problem is that it's assigned later in the request processing (when RGWListBucket_ObjStore_S3::get_params() is called by RGWListBucket::execute()), so you won't have access to it here. you probably want to just check s->info.args.exists("versions")

edit: or, move the call to get_params() into this function, like you did with RGWDeleteMultiObj below

try {
rgw::IAM::Policy p(s->cct, s->bucket_tenant, policy_text);
auto attrs = s->bucket_attrs;
attrs[RGW_ATTR_IAM_POLICY];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like something is missing here. what are we doing with p?

return cmp_addr6((sockaddr_in6*) addrl,
(sockaddr_in6*) addrr,
prefix_len);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO?

// This assumes a contiguous block of numbers in the correct order.
uint16_t digit(char c) {
if (!(c >= '0' && c <= '9'))
throw std::invalid_argument("Not a digit.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: CodingStyle, single-line blocks still get enclosed in { }

@adamemerson adamemerson force-pushed the wip-sts-authorization branch 2 times, most recently from ddb1c95 to f0e1d1a Compare April 10, 2017 21:21
@adamemerson adamemerson changed the title DNM: RGW Bucket Policies RGW Bucket Policies Apr 11, 2017
}

Effect Statement::eval(const Environment& e,
optional<const rgw::auth::Identity&> ida,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamemerson: is there a reason for taking the optional reference here? Although boost::optional is able to do that, some restrictions exist.

Maybe pointer-to-const would be a simpler approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I wanted to make it explicit in the function signature that the parameter was optional. const pointers /can/ be nulled, but it's less obvious to people reading the code whether the function does something useful with a null value instead of crashing or returning an error.

(If we were using the GSL we could use the not_null template which accomplishes the same thing.)

@adamemerson adamemerson force-pushed the wip-sts-authorization branch 7 times, most recently from 7579716 to 0ab3cf5 Compare May 2, 2017 16:48
@adamemerson adamemerson force-pushed the wip-sts-authorization branch 3 times, most recently from dbc8de6 to cfc3755 Compare May 4, 2017 19:40
@adamemerson
Copy link
Contributor Author

@tchaikov I just wanted to get a checkmark before he logged out for the day, if I could.

@adamemerson
Copy link
Contributor Author

@yehudasa If you want the submodule to point to a repository living under the Ceph project, you'll need to get someone who has access to put it there. I think it would be better to leave it pointing to the original repository until we have good reason to move it, since that makes adopting changes easier.

@adamemerson
Copy link
Contributor Author

@yehudasa At least I'm pretty sure I don't have access to create a new repo under the Ceph project.

Copy link
Contributor

@cbodley cbodley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approval pending submodule

@tchaikov
Copy link
Contributor

tchaikov commented May 16, 2017

@adamemerson sorry, Adam. i thought you were about to merge. didn't intent to block you anyway.

Copy link
Contributor

@rzarzynski rzarzynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamemerson: LGTM. Thanks for bringing this feature and sorry for late response.

}

return d;
} catch (const std::logic_error& e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::logic_error looks very reasonable here.

There are parts of C++14 that are both useful and easy to
implement. This is one of them.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
This is a high performance, MIT licensed JSON parsing library. It
provides a SAX interface so that I can compile an S3 policy without
building up a JSONObject tree in the middle that gets thrown away.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Copy link
Contributor

@tchaikov tchaikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submodule inclusion lgtm.

};

template<typename T, typename... Args>
inline typename uniquity<T>::datum make_unique(Args&&... args) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this!

TEST(iso_8601, epoch) {
const auto epoch = real_clock::from_time_t(0);

ASSERT_EQ(to_iso_8601(epoch, iso_8601_format::Y), "1970");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, the lhs is the expected value, while the rhs is the actual one.

/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Red Hat <contact@redhat.com>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i also miss 2014 for some reason.

For parsing and unparsing from ceph::real_time.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Eventually this will allow us to match all authentication information
against all specified principals in a policy.

Right now it handles users and wildcards.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
So they can be used when calling the function

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Make three wrapper functions to tidy up the process of making a
bufferlist holding a single static buffer.

The lack of any decent handling of const in buffer::list makes me wax
wroth, but it's a bit much to fix right now.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
This support is currently incomplete but should provide a starting
point.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Only hook into object/bucket checks for now. Once we have STS (giving
us Roles) or User/Group policies it will make sense to hook into
those, too.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
@adamemerson adamemerson merged commit 80b285d into ceph:master May 17, 2017
adamemerson added a commit that referenced this pull request May 17, 2017
Merge pull request #14307 from adamemerson/wip-sts-authorization

common: Add make_unique
submodule: Tencent's RapidJSON library
common: Add ISO-8601 Date Support
rgw: Add is_identity to AuthApplier class
rgw: Move globbing flags to header
buffer: Make the use of static areas more convenient
rgw: Add basic support for IAM policies
rgw: Build bucket permission and environment in req_state
rgw: Verify policies as WELL as ACLs
rgw: RESTful bucket policy ops
rgw: Write documentation for bucket policies

Reviewed-By: Casey Bodley <cbodley@redhat.com>
Reviewed-By: Radoslaw Zarzynski <rzarzynski@mirantis.com>
Reviewed-By: Kefu Chai <kchai@redhat.com>
@adamemerson adamemerson deleted the wip-sts-authorization branch May 17, 2017 20:10
// Statement

} else if (w->id == TokenID::Sid) {
t->sid.emplace(s, l);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants