Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot enable or disable users in realm #25

Closed
Jopie01 opened this issue Apr 6, 2023 · 3 comments
Closed

Cannot enable or disable users in realm #25

Jopie01 opened this issue Apr 6, 2023 · 3 comments

Comments

@Jopie01
Copy link

Jopie01 commented Apr 6, 2023

I get an error when I want to enable or disable a user. Using wick from the documentation

/wick --url ws://localhost:18080/ws \
--realm com.leapsight.bondy \
call bondy.realm.security.disable "com.leapsight.test_creation_1"

I get

FATA[0000] got errors:
- calling remote procedure 'bondy.user.disable': bondy.error.function_clause: : code=function_clause, description=, message= 

Using curl

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.user.enable",
    "options": {},
    "args": [
      "com.leapsight.test",
      "peer1"
    ],
    "kwargs": {}
  }'

I get

{"args":[""],"details":{},"error_uri":"bondy.error.function_clause","kwargs":{"code":"function_clause","description":"","message":""}}

Digging / tracing through the code and trying to debug, the error comes from:

disable(RealmUri, #{type := ?USER_TYPE} = User) ->
case update(RealmUri, User, #{enabled => false}) of
{ok, _} -> ok;
Error -> Error
end.

The problem is that the User send is a Binary and it seems that the function is expecting something different. Removing the type check will fix the problem and I can enable and disable an user. But I don't think that's the right thing to do right? I suppose it should be fixed in

handle_call(?BONDY_USER_ENABLE, #call{} = M, Ctxt) ->

All the above happens for both enable and disable an user.

@aramallo
Copy link
Contributor

aramallo commented Apr 6, 2023

Thanks @Jopie01 I’ll take a look tomorrow and get back to you.

@aramallo
Copy link
Contributor

aramallo commented Apr 6, 2023

@Jopie01 Just made a commit to develop fixing this issue and improving some other validations.

If you do:

wick --url ws://localhost:18080/ws --realm com.leapsight.test \
call bondy.user.enable "app1"

No return

Then:

wick --url ws://localhost:18080/ws --realm com.leapsight.test \
call bondy.user.is_enabled "app1"

should return

[ 
   false
]

@Jopie01
Copy link
Author

Jopie01 commented Apr 6, 2023

@aramallo Thanks! Did a pull and now it works perfectly!

Also using curl is working with

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.user.enable",
    "options": {},
    "args": [
      "com.leapsight.test",
      "peer1"
    ],
    "kwargs": {}
  }'

And replacing bondy.user.enable with bondy.user.disable is also working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants