Skip to content

Instantly share code, notes, and snippets.

@Vagabond
Last active December 19, 2015 16:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vagabond/6222793a1d352f1ccdd2 to your computer and use it in GitHub Desktop.
Save Vagabond/6222793a1d352f1ccdd2 to your computer and use it in GitHub Desktop.
Riak PBC security session
6> {ok, PB} = riakc_pb_socket:start("127.0.0.1", 8087, [{credentials, "andrew", "foo"}]).
{ok,<0.59.0>}
7> riakc_pb_socket:get(PB, <<"hello">>, <<"world">>).
{error,<<"Permission riak_kv.get denied to user andrew on hello">>}

./rel/riak/bin/riak-admin security grant riak_kv.get ON default hello TO andrew

12> riakc_pb_socket:get(PB, <<"hello">>, <<"world">>).
{error,notfound}
13> riakc_pb_socket:put(PB, riakc_obj:new(<<"hello">>, <<"world">>, <<"howareyou">>)).
{error,<<"Permission riak_kv.put denied to user andrew on hello">>}

./rel/riak/bin/riak-admin security grant riak_kv.put ON default hello TO andrew

17> riakc_pb_socket:put(PB, riakc_obj:new(<<"hello">>, <<"world">>, <<"howareyou">>)).
ok
18> riakc_pb_socket:get(PB, <<"hello">>, <<"world">>).
{ok,{riakc_obj,<<"hello">>,<<"world">>,
               <<107,206,97,96,96,96,204,96,202,5,82,28,202,156,255,126,
                 6,94,103,157,146,193,148,...>>,
               [{{dict,2,16,16,8,80,48,
                       {[],[],[],[],[],[],[],[],[],[],[],[],...},
                       {{[],[],[],[],[],[],[],[],[],[],...}}},
                 <<"howareyou">>}],
               undefined,undefined}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment