Code Monkey home page Code Monkey logo

Comments (6)

aramallo avatar aramallo commented on May 19, 2024

Hi @Jopie01 you are correct.

The issue is that not all Admin WAMP Procedures are exposed via the Admin HTTP API right now.

Just to check, for a user in your realm to be able to authenticate using a particular methods you need:

  1. The realm to have the method listed in its authmethods property
  2. The realm to have a sources rule where usernames is the string all or is a list of usernames which includes the user.

We are currently working on implementing and documenting all the HTTP API (I added Issue #21 to track this activity ).

In the meantime, you can operate on your Realm's sources using the WAMP API, please check the docs for bondy.source.add.

You could use Wick as you use CURL to call that procedure 😄 .

For example to allow myusername to authenticate into com.myrealm using password when connecting from any network you would use.

./wick --url ws://localhost:18081/ws \
--realm com.leapsight.bondy \
call bondy.source.add \
"com.myrealm" \
'{
	"usernames":["myusername"],
	"authmethod":"password",
	"cidr":"0.0.0.0/0"
}' | jq

from bondy.

aramallo avatar aramallo commented on May 19, 2024

@Jopie01 there is another option via HTTP.

You can use the (undocumented) /services/call HTTP API

curl -X "POST" "http://localhost:18081/services/call" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -H 'Accept: application/json; charset=utf-8' \
     -d $'{
  "procedure": "bondy.source.add",
  "arguments": [
    "com.myrealm",
    {
        "usernames":["myusername"],
	"authmethod":"password",
	"cidr":"0.0.0.0/0"
    }
  ],
  "options": {},
  "arguments_kw": {}
}'

from bondy.

Jopie01 avatar Jopie01 commented on May 19, 2024

@aramallo Thanks for the answer. I have already a running instance of Bondy with two users, but these are configured in the security_config.json and that works well. But now I want to add a third user which I want to add through the api.

When I execute

curl -X "POST" "http://localhost:18081/services/call" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -H 'Accept: application/json; charset=utf-8' \
     -d $'{
  "procedure": "bondy.source.add",
  "arguments": [
    "com.example.realm",
    {
        "usernames":["client1", "client2", "client3"],
	"authmethod":"cryptosign",
	"cidr":"0.0.0.0/0"
    }
  ],
  "options": {},
  "arguments_kw": {}
}'

I get this error back:

{
    "code": "bondy.error.http_gateway.invalid_expression",
    "description": "This might be due to an error in the action expression (mops) itself or as a result of a key missing in the response to a gateway action (WAMP or HTTP call).",
    "message": "There is no value for path 'requestbodyargs' in the HTTP Request context."
}

Just to mention that I want to add "client3" as the new user. The other two users are already there. I don't know if it is enough to only send the new user and that Bondy will take care to add the new user to the already existing list of usernames.

from bondy.

aramallo avatar aramallo commented on May 19, 2024

Arggg. Sorry @Jopie01 my bad, I was using an old snippet.

Can you try with the following?

curl -X "POST" "http://localhost:18081/services/call" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -H 'Accept: application/json; charset=utf-8' \
     -d $'{
  "procedure": "bondy.source.add",
  "options": {},
  "args": [
    "com.example.realm",
    {
        "usernames":["client1", "client2", "client3"],
	"authmethod":"cryptosign",
	"cidr":"0.0.0.0/0"
    }
  ],
  "kwargs": {}
}'

args instead of arguments and kwargs instead of arguments_kw.

from bondy.

aramallo avatar aramallo commented on May 19, 2024

Re your question

The other two users are already there. I don't know if it is enough to only send the new user and that Bondy will take care to add the new user to the already existing list of usernames.

Yes, you could just send the request with "usernames": ["client3"], as internally this will create a separate record per user (the other two users are already there)

from bondy.

Jopie01 avatar Jopie01 commented on May 19, 2024

@aramallo, thanks for the answers. Everything now works perfectly! Also the Wick one works.

from bondy.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.