Kibana User Session

Hi team,

I have a question that I’m having trouble finding the answer to elsewhere.

I would like to create dashboards that customize the data based on the specific user logged in.
The response of this api Post : http://xxxxxxxx:5601/internal/security/login includes a set-cookie header that contains the session information.

I need to join the data in my dashboard to the current user logged in.

e.g something like - professionalId .user : $currentSessionUser

My index looks like :slight_smile:
{
"_index" : "hotelsearch",
"_type" : "search",
"_id" : "1022427",
"_score" : 1.0,
"_source" : {
"professionalId" : 103,
"partnerId" : 25156,
"userAgent" : "Cold",
"checkOut" : "2021-09-08",
"clientNationality" : "TN",
"checkIn" : "2021-09-06",
"partner" : "user1",
"rating" : "",
"language" : "FRA",
"currency" : "TND",
"source" : "api",
"@version" : "1",
"channel" : "b2c",
"rooms" : [
{
"adults" : 2,
"children" : 0
}
],
"cityCode" : "104",
"cityId" : 3,
"dateTime" : "2021-09-04T10:10:17.973Z",
"id" : 1022427,
"@timestamp" : "2021-09-10T11:38:11.107Z",
"countryCode" : "TN",
"searchcode" : "5304191a-b60b-4356-86f2-980cfcc1a450"
}
},
{
"_index" : "hotelsearch",
"_type" : "search",
"_id" : "1022430",
"_score" : 1.0,
"_source" : {
"professionalId" : 10,
"partnerId" : 25156,
"userAgent" : "Cold",
"checkOut" : "2021-09-12",
"clientNationality" : "TN",
"checkIn" : "2021-09-10",
"partner" : "user2",
"rating" : "",
"language" : "FRA",
"currency" : "TND",
"source" : "api",
"@version" : "1",
"channel" : "b2c",
"rooms" : [
{
"children" : 2,
"adults" : 2,
"childrenAges" : [
"4",
"5"
]
}
],
"cityCode" : "104",
"cityId" : 3,
"dateTime" : "2021-09-04T10:10:27.629Z",
"id" : 1022430,
"@timestamp" : "2021-09-10T11:38:11.107Z",
"countryCode" : "TN",
"searchcode" : "a9eeb5b3-e5f5-426b-8d6b-6a100a993f44"
}
}

every user has login and password and a professionalId.
if the user 1 is logged, he will see only the data that refer to his professionalId

so haw can i pass this professionalId with the current session

any help please.

Best regards,
Hiba

Hey @hiba, unfortunately this is currently not a feature inside of Kibana. I have filed an Enhancement Request for it.

That said, it is currently possible to do this, but you would need to be quite technical. I can provide info on where to start, and can hopefully set you on the right path, but each step here is fairly complicated, and I haven't accomplished this before - I just know it is technically possible.

  1. generate an embed code for the dashboard you'd like to show with a filter applied for a user.
  2. Look at the generated URL inside the iframe. There should be a piece of the URL where the filter is defined. It might look something like query:(match_phrase:(professionalId .user:WHATEVERVALUE)
  3. Build a simple website which includes an iframe to show Kibana. Do not show the iframe yet.
  4. On startup of the website, send off a Post request to your login endpoint.
  5. When you receive the response, change the URL to reflect the currently logged in user.
  6. Show the iframe with the new kibana URL.
  7. Kibana should load the dashboard with that filter applied.

Hi @devon.thomson ,

Thanks for your reply,
i just want to know if it's possible to hide or encrypt this query

Yes, the filter bar can be hidden, by unchecking the 'filter bar' item when creating the embed code. That said, this will just hide the entire Filter bar, there is no way to hide only one filter.

Also, it does not prevent the user from potentially seeing data meant for another user. If the user has access to the index pattern, they can always use the API directly to access all of the data. You can use Document Level Security to stop them from seeing it.

Hi @devon.thomson ,

this look awesome thanks a lot,
but I got this error, when i use Document Level Security

{
"error" : {
"root_cause" : [
{
"type" : "security_exception",
"reason" : "current license is non-compliant for [field and document level security]",
"license.expired.feature" : "field and document level security"
}
],
"type" : "security_exception",
"reason" : "current license is non-compliant for [field and document level security]",
"license.expired.feature" : "field and document level security"
},
"status" : 403
}

hey @hiba, looks like Field- and document-level security is a platinum feature. Take a look at our subscriptions page for more info.

Even without Document Level Security, you can still apply and hide the filter. Users will only be able to see information for other users if they write the queries themselves.