kuzzleio / kuzzle

Open-source Back-end, self-hostable & ready to use - Real-time, storage, advanced search - Web, Apps, Mobile, IoT -
https://kuzzle.io
Apache License 2.0
1.44k stars 124 forks source link

Problem with profile hydratation on searchProfiles #282

Closed stafyniaksacha closed 8 years ago

stafyniaksacha commented 8 years ago

Given we make this request POST http://localhost:7511/api/1.0/profiles/_search

{
  "body": {
      "hydrate": true
  }
}

Kuzzle format profiles like :

{
  "_id": "admin",
  "_source": {
    "roles": [
      {
        "_id": "admin",
        "_source": {
          "allowInternalIndex": true,
          "controllers": {
            "*": {
              "actions": {
                "*": true
              }
            }
          }
        }
      }
    ]
  }
}

BUT in case we ask for non hydrated profiles POST http://localhost:7511/api/1.0/profiles/_search

{
  "body": {
      "hydrate": false
  }
}

Kuzzle respond a wired object

{
  "_id": "admin",
  "_source": {
    "roles": [
      {
        "_id": "admin",
        "allowInternalIndex": true
      }
    ]
  }
}

Instead of

{
  "_id": "admin",
  "_source": {
    "roles": [
      "admin"
    ]
  }
}
j33f commented 8 years ago

well spotted I take it

ballinette commented 8 years ago

Not a bug in my sense.

"non hydrated" profiles means in fact "non nested", that is without nested roles details. But the "allowInternalIndex" attribute, as well as the "restrictedTo" one, are set at profile level (see Permission documentation for more explanations). So the actual formating is ok.

Note we are planing to refactor the repositories, and then simplify the get/search Users/Profiles/Roles actions. The "hydrate= false" option will no longer be used and these actions will allways return a non-nested result. That means: for seachProfiles, the response format will allways be like actual one with "hydrate=false":

{
  "_id": "admin",
  "_source": {
    "roles": [
      {
        "_id": "admin",
        "allowInternalIndex": true
      }
    ]
  }
}
stafyniaksacha commented 8 years ago

resolved with #312