Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Logs ML] Check permissions before granting access to Logs ML p…
…ages (#195278) (#195759) # Backport This will backport the following commits from `main` to `8.x`: - [[Logs ML] Check permissions before granting access to Logs ML pages (#195278)](#195278) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Marco Antonio Ghiani","email":"marcoantonio.ghiani01@gmail.com"},"sourceCommit":{"committedDate":"2024-10-10T12:33:18Z","message":"[Logs ML] Check permissions before granting access to Logs ML pages (#195278)\n\n## 📓 Summary\r\n\r\nCloses #191206 \r\n\r\nThis work fixes issues while accessing the Logs Anomalies and Logs\r\nCategories pages due to a lack of user privileges.\r\n\r\nThe privileges were correctly handled until\r\nhttps://github.com//pull/168234 was merged, which\r\nintroduced a call to retrieve ml formats information higher in the React\r\nhierarchy before the privileges could be asserted for the logged user.\r\nThis was resulting in the call failing and letting the user stack in\r\nloading states or erroneous error pages.\r\n\r\nThese changes lift the license + ML read privileges checks higher in the\r\nhierarchy so we can display the right prompts before calling the ml\r\nformats API, which will resolve correctly if the user has the right\r\nprivileges.\r\n\r\n### User without valid license\r\n\r\n<img width=\"3008\" alt=\"Screenshot 2024-10-07 at 17 01 17\"\r\nsrc=\"https://github.com/user-attachments/assets/bf6478ce-b007-4f15-9538-c7959c497e8a\">\r\n\r\n### User with a valid license (or Trial), but no ML privileges\r\n\r\n<img width=\"3003\" alt=\"Screenshot 2024-10-07 at 17 03 48\"\r\nsrc=\"https://github.com/user-attachments/assets/c5a82159-b4e8-4f22-9531-23d5e5a9377f\">\r\n\r\n### User with a valid license (or Trial) and only Read ML privileges\r\n\r\n<img width=\"3003\" alt=\"Screenshot 2024-10-07 at 17 04 21\"\r\nsrc=\"https://github.com/user-attachments/assets/990f4695-e07e-46a2-9214-d0de3628caf7\">\r\n\r\n### User with a valid license (or Trial) and All ML privileges, which\r\nare the requirements to work with ML Logs features\r\n\r\n<img width=\"3000\" alt=\"Screenshot 2024-10-07 at 17 04 52\"\r\nsrc=\"https://github.com/user-attachments/assets/c9b4d832-d3c8-4337-9e17-8a220e7be084\">\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>","sha":"e0e4ec10e3c329f933bed0a01dbeaecdf79cfa99","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Logs UI","release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-logs"],"title":"[Logs ML] Check permissions before granting access to Logs ML pages","number":195278,"url":"https://github.com/elastic/kibana/pull/195278","mergeCommit":{"message":"[Logs ML] Check permissions before granting access to Logs ML pages (#195278)\n\n## 📓 Summary\r\n\r\nCloses #191206 \r\n\r\nThis work fixes issues while accessing the Logs Anomalies and Logs\r\nCategories pages due to a lack of user privileges.\r\n\r\nThe privileges were correctly handled until\r\nhttps://github.com//pull/168234 was merged, which\r\nintroduced a call to retrieve ml formats information higher in the React\r\nhierarchy before the privileges could be asserted for the logged user.\r\nThis was resulting in the call failing and letting the user stack in\r\nloading states or erroneous error pages.\r\n\r\nThese changes lift the license + ML read privileges checks higher in the\r\nhierarchy so we can display the right prompts before calling the ml\r\nformats API, which will resolve correctly if the user has the right\r\nprivileges.\r\n\r\n### User without valid license\r\n\r\n<img width=\"3008\" alt=\"Screenshot 2024-10-07 at 17 01 17\"\r\nsrc=\"https://github.com/user-attachments/assets/bf6478ce-b007-4f15-9538-c7959c497e8a\">\r\n\r\n### User with a valid license (or Trial), but no ML privileges\r\n\r\n<img width=\"3003\" alt=\"Screenshot 2024-10-07 at 17 03 48\"\r\nsrc=\"https://github.com/user-attachments/assets/c5a82159-b4e8-4f22-9531-23d5e5a9377f\">\r\n\r\n### User with a valid license (or Trial) and only Read ML privileges\r\n\r\n<img width=\"3003\" alt=\"Screenshot 2024-10-07 at 17 04 21\"\r\nsrc=\"https://github.com/user-attachments/assets/990f4695-e07e-46a2-9214-d0de3628caf7\">\r\n\r\n### User with a valid license (or Trial) and All ML privileges, which\r\nare the requirements to work with ML Logs features\r\n\r\n<img width=\"3000\" alt=\"Screenshot 2024-10-07 at 17 04 52\"\r\nsrc=\"https://github.com/user-attachments/assets/c9b4d832-d3c8-4337-9e17-8a220e7be084\">\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>","sha":"e0e4ec10e3c329f933bed0a01dbeaecdf79cfa99"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195278","number":195278,"mergeCommit":{"message":"[Logs ML] Check permissions before granting access to Logs ML pages (#195278)\n\n## 📓 Summary\r\n\r\nCloses #191206 \r\n\r\nThis work fixes issues while accessing the Logs Anomalies and Logs\r\nCategories pages due to a lack of user privileges.\r\n\r\nThe privileges were correctly handled until\r\nhttps://github.com//pull/168234 was merged, which\r\nintroduced a call to retrieve ml formats information higher in the React\r\nhierarchy before the privileges could be asserted for the logged user.\r\nThis was resulting in the call failing and letting the user stack in\r\nloading states or erroneous error pages.\r\n\r\nThese changes lift the license + ML read privileges checks higher in the\r\nhierarchy so we can display the right prompts before calling the ml\r\nformats API, which will resolve correctly if the user has the right\r\nprivileges.\r\n\r\n### User without valid license\r\n\r\n<img width=\"3008\" alt=\"Screenshot 2024-10-07 at 17 01 17\"\r\nsrc=\"https://github.com/user-attachments/assets/bf6478ce-b007-4f15-9538-c7959c497e8a\">\r\n\r\n### User with a valid license (or Trial), but no ML privileges\r\n\r\n<img width=\"3003\" alt=\"Screenshot 2024-10-07 at 17 03 48\"\r\nsrc=\"https://github.com/user-attachments/assets/c5a82159-b4e8-4f22-9531-23d5e5a9377f\">\r\n\r\n### User with a valid license (or Trial) and only Read ML privileges\r\n\r\n<img width=\"3003\" alt=\"Screenshot 2024-10-07 at 17 04 21\"\r\nsrc=\"https://github.com/user-attachments/assets/990f4695-e07e-46a2-9214-d0de3628caf7\">\r\n\r\n### User with a valid license (or Trial) and All ML privileges, which\r\nare the requirements to work with ML Logs features\r\n\r\n<img width=\"3000\" alt=\"Screenshot 2024-10-07 at 17 04 52\"\r\nsrc=\"https://github.com/user-attachments/assets/c9b4d832-d3c8-4337-9e17-8a220e7be084\">\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>","sha":"e0e4ec10e3c329f933bed0a01dbeaecdf79cfa99"}}]}] BACKPORT--> Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani01@gmail.com>
- Loading branch information