Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding attributes to IBM Bluemix Blockchain CA(membersrvc.yaml)

I'm working on a proof of concept for blockchain. I've am using bluemix network for blockchain and deploying my application, which I develop locally. I want to test the CA functionalities and want to add users with attributes to the membersrvs.yaml , and perform Attribute Based Access control. However, I'm not able to find out how can I edit/update the file while my network is hosted on bluemix. Pardon me if this seems very basic, I'm still getting a hang on things.

like image 688
tortuga Avatar asked Jul 19 '16 15:07

tortuga


1 Answers

You cannot edit/customize membersrvs.yaml that resides in the Bluemix Blockchain Service.

However, you can still add users via an API. This is not exposed via the REST interface, you will have to use gRPC (via the HFC SDK). There is an example in the demo "cp-web" line 76 (also below)

/**
 * Registers a new user in the membership service for the blockchain network.
 * @param enrollID The name of the user we want to register.
 * @param cb A callback of the form: function(error, user_credentials)
 */
module.exports.registerUser = function (enrollID, cb) {
    console.log(TAG, 'registerUser() called');

    if (!chain) {
        cb(new Error('Cannot register a user before setup() is called.'));
        return;
    }

    chain.getMember(enrollID, function (err, usr) {
        if (!usr.isRegistered()) {
            console.log(TAG, 'Sending registration request for:', enrollID);
            var registrationRequest = {
                enrollmentID: enrollID,
                affiliation: 'group1'
            };
            usr.register(registrationRequest, function (err, enrollSecret) {
                if (err) {
                    cb(err);
                } else {
                    var cred = {
                        id: enrollID,
                        secret: enrollSecret
                    };
                    console.log(TAG, 'Registration request completed >successfully!');
                    cb(null, cred);
                }
           });
        } else {
            cb(new Error('Cannot register an existing user'));
        }
    });
};
like image 114
unknown Avatar answered Jan 24 '23 21:01

unknown