From: Ashutosh Narkar Date: Wed, 30 May 2018 23:49:30 +0000 (-0700) Subject: Initial work for OPA-Ceph integration X-Git-Tag: v14.0.1~784^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=631a036a6b02d30d12d0a1c6cae25c9aa0c38af1;p=ceph.git Initial work for OPA-Ceph integration Signed-off-by: Ashutosh Narkar --- diff --git a/doc/radosgw/index.rst b/doc/radosgw/index.rst index fa9915c4819..37ff9305de7 100644 --- a/doc/radosgw/index.rst +++ b/doc/radosgw/index.rst @@ -49,6 +49,7 @@ you may write data with one API and retrieve it with the other. Export over NFS OpenStack Keystone Integration OpenStack Barbican Integration + Open Policy Agent Integration Multi-tenancy Compression LDAP Authentication diff --git a/doc/radosgw/opa.rst b/doc/radosgw/opa.rst new file mode 100644 index 00000000000..18d7f6d6a75 --- /dev/null +++ b/doc/radosgw/opa.rst @@ -0,0 +1,71 @@ +============================== +Open Policy Agent Integration +============================== + +Open Policy Agent (OPA) is a lightweight general-purpose policy engine +that can be co-located with a service. OPA can be integrated as a +sidecar, host-level daemon, or library. + +Services can offload policy decisions to OPA by executing queries. Hence, +policy enforcement can be decoupled from policy decisions. + +Configure OPA +============= + +To configure OPA, load custom polices into OPA that control the resources users +are allowed to access. Relevant data or context can also be loaded into OPA to make decisions. + +Polices and data can be loaded into OPA in the following ways:: + * OPA's RESTful APIs + * OPA's *bundle* feature that downloads polcies and data from remote HTTP servers + * Filesystem + +Configure the Ceph Object Gateway +================================= + +The following configuration options are available for OPA integration:: + + rgw use opa authz = {use opa server to authorize client requests} + rgw opa url = {opa server url:opa server port} + rgw opa token = {opa bearer token} + rgw opa verify ssl = {verify opa server ssl certificate} + +How does the RGW-OPA integration work +===================================== + +After a user is authenticated, OPA can be used to check if the user is authorized +to perform the given action on the resource. OPA responds with an allow or deny +decision which is sent back to the RGW which enforces the decision. + +Example request:: + + POST /v1/data/ceph/authz HTTP/1.1 + Host: opa.example.com:8181 + Content-Type: application/json + + { + "input": { + "method": "GET", + "user_info": { + "used_id": "john", + "display_name": "John" + }, + "bucket_info": { + "bucket": { + "name": "Testbucket", + "bucket_id": "testbucket" + }, + "owner": "john" + } + } + } + +Response:: + + {"result": true} + +The above is a sample request sent to OPA which contains information about the +user, resource and the action to be performed on the resource. Based on the polices +and data loaded into OPA, it will verify whether the request should be allowed or denied. +In the sample request, RGW makes a POST request to the endpoint */v1/data/ceph/authz*, +where *ceph* is the package name and *authz* is the rule name. diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index 6a38549b33b..1fe4525722f 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -1338,6 +1338,10 @@ OPTION(rgw_s3_auth_use_rados, OPT_BOOL) // should we try to use the internal cr OPTION(rgw_s3_auth_use_keystone, OPT_BOOL) // should we try to use keystone for s3? OPTION(rgw_s3_auth_order, OPT_STR) // s3 authentication order to try OPTION(rgw_barbican_url, OPT_STR) // url for barbican server +OPTION(rgw_opa_url, OPT_STR) // url for OPA server +OPTION(rgw_opa_token, OPT_STR) // Bearer token OPA uses to authenticate client requests +OPTION(rgw_opa_verify_ssl, OPT_BOOL) // should we try to verify OPA's ssl +OPTION(rgw_use_opa_authz, OPT_BOOL) // should we use OPA to authorize client requests? /* OpenLDAP-style LDAP parameter strings */ /* rgw_ldap_uri space-separated list of LDAP servers in URI format */ diff --git a/src/common/options.cc b/src/common/options.cc index 82c34ad88e5..1226c54349a 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -5362,6 +5362,22 @@ std::vector