Search code examples
spring-data-couchbase

Multiple buckets authentication with Admin user


I have multiple buckets and on my existing config I have a user for each bucket where the username is the name of the bucket and the password is a single password for all the buckets.. this is functioning as a work-around for rbac that was released with 5.x and the removal of bucket-level passwords.

Now I've spent many hours today figuring out how I can control all the buckets with a single admin user (in order for me to finally get rid of the many un-neccessary users) New admin user

I'm running latest couchbase 5.5.2 and spring-data-couchbase 3.1.1.RELEASE which should have the rbac support as mentioned here

The documentation doesn't mention how I can achieve this and the comments in the github link above are vague and I can't figure it out.


Solution

  • Finally figured it out.

    You'll need to overwrite following method from AbstractCouchbaseConfiguration, specifying the rbac user

    @Override
    protected String getUsername() {
        return "Admin";
    }
    

    Then change all your bucket beans to use openBucket(String s1) instead of openBucket(String s1, String s2)

    @Bean
    public Bucket kBucket() throws Exception {
        return couchbaseCluster().openBucket("buck");
    }