azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[BUG] PermissionScope.withPermissions can not add list

Open alice36 opened this issue 3 years ago • 21 comments

I would like to add read and list role to permissions, from the code I see it is possible

/*
 * The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and
 * Create (c).
 */
@JsonProperty(value = "permissions", required = true)
private String permissions;

and also the same in the documentation

permissions | string | The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create (c).

But on trial I receive an error: Status code 400, "{"error":{"code":"InvalidRequestPropertyValue","message":"The value 'rl' is not allowed for property permissionScope.permissions."}}"

Could you please advise?

alice36 avatar Mar 30 '23 13:03 alice36

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @weidongxu-microsoft, @XiaofeiCao

ghost avatar Mar 30 '23 16:03 ghost

@weidongxu-microsoft, @XiaofeiCao, this is in azure-resourcemanager-storage to make finding this easier

alzimmermsft avatar Mar 30 '23 16:03 alzimmermsft

@alice36

Does "r" or "l" work? From the doc, it does not say the combination of them can work (hence backend could reject "rl").

weidongxu-microsoft avatar Mar 31 '23 00:03 weidongxu-microsoft

@weidongxu-microsoft Yes, "r", "rw", "rwd" - I tried those combination and it works. For single l I received an error: "The value 'l' is not allowed for property permissionScope.permissions."

alice36 avatar Mar 31 '23 06:03 alice36

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Issue Details

I would like to add read and list role to permissions, from the code I see it is possible

/*
 * The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and
 * Create (c).
 */
@JsonProperty(value = "permissions", required = true)
private String permissions;

and also the same in the documentation

permissions | string | The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create (c).

But on trial I receive an error: Status code 400, "{"error":{"code":"InvalidRequestPropertyValue","message":"The value 'rl' is not allowed for property permissionScope.permissions."}}"

Could you please advise?

Author: alice36
Assignees: XiaofeiCao
Labels:

question, Storage, Service Attention, Mgmt, customer-reported

Milestone: -

ghost avatar Mar 31 '23 06:03 ghost

Got it. Looping in backend, as storage control-plane seems having problem with "l" as permission.

weidongxu-microsoft avatar Mar 31 '23 06:03 weidongxu-microsoft

@weidongxu-microsoft @XiaofeiCao do we have any update?

alice36 avatar Apr 11 '23 18:04 alice36

@xgithubtriage any update on storage control-plane?

Add @blueww for help if possible.

@alice36 Would you confirm it is this API? https://learn.microsoft.com/en-us/rest/api/storagerp/local-users/create-or-update?tabs=Java

weidongxu-microsoft avatar Apr 12 '23 02:04 weidongxu-microsoft

@weidongxu-microsoft yes, this is correct API.

alice36 avatar Apr 12 '23 09:04 alice36

@alice36

Check with backend. "l" or "rl" works well for "blob" service (.withService("blob")), but not "file" service.

Is your use case indeed the "file" service? Could you describe it?

weidongxu-microsoft avatar Apr 13 '23 03:04 weidongxu-microsoft

@weidongxu-microsoft I'm using it to add permissions to a container to specific sftp local user: PermissionScope permissionScope = new PermissionScope() .withPermissions()..

alice36 avatar Apr 13 '23 10:04 alice36

@alice36 I assume "container" would be .withService("blob") (not "file")? Would you show us this part of the code?

weidongxu-microsoft avatar Apr 14 '23 01:04 weidongxu-microsoft

@weidongxu-microsoft I'm using this .withService("container")

alice36 avatar Apr 14 '23 06:04 alice36

@weidongxu-microsoft but I've observed also since yestarday that sth strange is on Azure UI when trying to add All permissions to the blob to the specific sftp local user: image but for created earlier it works: image

alice36 avatar Apr 14 '23 06:04 alice36

Yeah, that is not a SDK issue, it is REST API issue, so everywhere will have same error.

Add @HimanshuChhabra and @prpandey3004 from SRP on question of whether "l" is allowed for "container", on API https://learn.microsoft.com/en-us/rest/api/storagerp/local-users/create-or-update?tabs=HTTP

      {
        "permissions": "l",
        "service": "container",
        "resourceName": "share2"
      }

weidongxu-microsoft avatar Apr 14 '23 06:04 weidongxu-microsoft

@weidongxu-microsoft this is PermissionScope class path com.azure.resourcemanager.storage.models.PermissionScope; from azure-resourcemanager-storage:2.22.0

alice36 avatar Apr 14 '23 06:04 alice36

@alice36

This is a storage server side issue , it looks the server behavior is not aligned with the swagger spec .

This is not java SDK specific issue, it can't be resolved by java SDK update only. When server/swagger is fixed and aligned, java sdk will also work (might need regeneration from fixed swagger).

Would you please report a storage server issue, and follow up this issue with server team? You can report it on portal as following picture: image

blueww avatar Apr 18 '23 06:04 blueww

Any update on this issue? Trying to add a new SFTP Local User via REST API, but getting this error:


{
    "error": {
        "code": "InvalidRequestPropertyValue",
        "message": "The value 'rwdlc' is not allowed for property permissionScope.permissions."
    }
}

Seems like any permission with l (for list) in it fails.

nickstucko avatar May 22 '24 19:05 nickstucko

FYI, I cannot update the Local User in Azure Portal either after creating it via the REST API

Screen Shot 2024-05-22 at 11 44 29 PM

nickstucko avatar May 23 '24 05:05 nickstucko

Got it working - the issue was in the permissionScopes.service property of my request body to the Azure Storage REST API Endpoint. I needed to use "blob" instead of "file".

This was my initial request body that was failing:

{
  "properties": {
    "permissionScopes": [
      {
        "permissions": "rwdcl",
        "service": "file",
        "resourceName": "partner-data"
      }
    ],
    "hasSshPassword": false,
    "hasSharedKey": false,
    "hasSshKey": false
  }
}

Removing the l (for list) from the above permissionScopes.permissions property would get the Local User created in Azure. But I couldn't login via SFTP. I also couldn't add any permission that included l (for list) in the Azure Portal UI.

I realized I needed to change permissionScopes.service to "blob", like this:


{
  "properties": {
    "permissionScopes": [
      {
        "permissions": "rwdcl",
        "service": "blob",
        "resourceName": "partner-data"
      }
    ],
    "hasSshPassword": false,
    "hasSharedKey": false,
    "hasSshKey": false
  }
}

Using this updated request body works perfectly and I can login now when testing with FileZilla with the programatically generated Local User.

nickstucko avatar May 23 '24 06:05 nickstucko