perl-Couchbase-Client icon indicating copy to clipboard operation
perl-Couchbase-Client copied to clipboard

Enable RBAC support (added the "username" option in constructor)

Open annibale-x opened this issue 6 years ago • 1 comments

ADDED THE SUPPORT FOR RBAC.

The Perl and the XS constructors allow the username in addition of the password option, enabling the Role Based Access Control introduced from Couchbase Server version 4.5.

Perl constructor usage:

use Couchbase::Bucket ;
my $bucket = Couchbase::Bucket->new(   
	"couchbase://127.0.0.1/bucket-name", 
	{ 
		username =>  "myUserName" ,  # <== new option 
		password => 'myPassword'
	}
) ;

APPLIED PATCH

--- xs/Couchbase.xs.orig	Mon Jul 23 23:41:36 2018
+++ xs/Couchbase.xs	Mon Jul 23 23:42:10 2018
@@ -36,6 +36,7 @@ PLCB_construct(const char *pkg, HV *hvopts)
     PLCB_t *object;
     plcb_OPTION options[] = {
         PLCB_KWARG("connstr", CSTRING, &cr_opts.v.v3.connstr),
+        PLCB_KWARG("username", CSTRING, &cr_opts.v.v3.username),
         PLCB_KWARG("password", CSTRING, &cr_opts.v.v3.passwd),
         PLCB_KWARG("io", SV, &iops_impl),
         PLCB_KWARG("on_connect", CV, &conncb),

INSTALLATION

The xs/Couchbase.xs was already patched with this commit. Just compile and install the Couchbase Perl module as usual:

 perl Makerfile.PL
 make
 make install

POD

Only the POD of Couchbase/Bucket.pm was updated.

TESTS

Tests were not updated and the module was not well tested. Just only the connection and the RBAC compliance have been tested.

annibale-x avatar Jul 24 '18 19:07 annibale-x

@mnunberg will there be a chance to have this merged and pushed to CPAN?

cc32d9 avatar Jul 10 '19 13:07 cc32d9