duo_client_java icon indicating copy to clipboard operation
duo_client_java copied to clipboard

Allow duplicate params when crafting the request

Open pvazqu1 opened this issue 2 years ago • 9 comments

According to the API documentation (retrieve-users), to retrieve specific users you need to specify the params like this:

usernames=cjones&usernames=mwong

On my request I've done something like this:

request.addParam("usernames", "cjones");
request.addParam("usernames", "mwong");

As a response I'm getting information about only one user. I believe the problem is that the addParam method is adding fields to a TreeMap:

private SortedMap<String, Object> params = new TreeMap<String, Object>();

Since we can't have duplicate keys, we can't search for multiple users. I've also noticed that you can set a List as value on the addParam method. Something like this:

request.addParam("username", Arrays.asList("cjones", "mwong"));

But that's also not working, the raw response is:

{"stat":"OK","response":[]}

pvazqu1 avatar May 31 '23 19:05 pvazqu1

@pvazqu1 The intent is that passing the list is the correct approach for having multiple values, so we'll look into this and see why that isn't having the intended effect.

AaronAtDuo avatar Jun 07 '23 20:06 AaronAtDuo

@pvazqu1 Hi! Thank you for report this issues. I do find a bug in our code and working on a fix now.

Just a side note, the example you give you used username instead usernames for

request.addParam("username", Arrays.asList("cjones", "mwong"));

I tried the usernames my self yet still not working.

yizshi avatar Jun 08 '23 14:06 yizshi

Hey guys, do you have an estimate regarding when this will be fixed? For now I'm just using a work around but it would be awesome just to use this client. Thanks!

pvazqu1 avatar Jun 13 '23 17:06 pvazqu1

@pvazqu1 No estimate yet... it looks like the bug has been around a while so we're investigating it to see if/how it ever worked.

AaronAtDuo avatar Jun 15 '23 15:06 AaronAtDuo

@pvazqu1 You uncovered quite a can of worms with our APIs that accept duplicate query string parameters. we're still working on a solution that won't break all existing clients.

AaronAtDuo avatar Aug 09 '23 14:08 AaronAtDuo

@AaronAtDuo I understand. Sorry about that 😣

pvazqu1 avatar Aug 16 '23 21:08 pvazqu1

@pvazqu1 We've determined that having the duplicate query string parameters option was not going to be feasible, so our engineers are working on introducing a new way of specifying multiple users. When that's ready we'll update this SDK.

AaronAtDuo avatar Sep 15 '23 15:09 AaronAtDuo

@pvazqu1 The new bulk endpoints that handle multiple parameters better have been released. The new way to retrieve multiple users is via the username_list parameter which replaces use of multiple username parameters. username_list should be a JSON-serialized array (i.e. a string). See the updated https://duo.com/docs/adminapi#retrieve-users for details.

Since this new parameter will just be a string, I think it should work with the existing client, but we haven't tested it yet; let us know if there's problems please.

AaronAtDuo avatar Oct 06 '23 15:10 AaronAtDuo

I am hoping #77 will help with this. When #77 merged, you could use something like

request.addParam("username_list", new JSONArray(new ArrayList(Arrays.asList("username1", "username2", "username3"))));

yizshi avatar Oct 10 '23 20:10 yizshi