mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 08:09:27 +00:00
### **User description**
Root user by default can access all the organizations and does not need
to be added to any organizations through api.
___
### **PR Type**
Bug fix, Tests
___
### **Description**
- Prevent adding root user to orgs
- Return Forbidden for unauthorized add attempts
- Expand integration tests for user/org flows
- Validate user listing includes expected emails
___
### Diagram Walkthrough
```mermaid
flowchart LR
addUser["add_user_to_org handler"] -- "user is root" --> rejectRoot["400 Bad Request: root no org needed"]
addUser -- "not root & unauthorized" --> forbid["403 Forbidden"]
tests["Integration tests"] -- "root add attempt" --> expect400["expect failure"]
tests -- "create non-root & add to org" --> expect200["expect success"]
tests -- "list users" --> assertUsers["assert expected emails present"]
```
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>users.rs</strong><dd><code>Block root user org add; use
403 for denial</code>
</dd></summary>
<hr>
src/service/users.rs
<ul><li>Short-circuit if <code>existing_user.is_root</code>, return
400.<br> <li> Change unauthorized response from 401 to 403.<br> <li> Add
explanatory comments for root access.</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8632/files#diff-98da2588a28d62bb2e301d989836125f89f89b76272cd7f75e08ec4deeea5f38">+13/-2</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>integration_test.rs</strong><dd><code>Extend
integration tests for user/org behaviors</code>
</dd></summary>
<hr>
tests/integration_test.rs
<ul><li>Import <code>UserList</code> and validate list users
content.<br> <li> Add <code>e2e_add_root_user_to_org</code> expecting
failure.<br> <li> Add <code>e2e_add_user_to_org</code> to create and add
admin user.<br> <li> Update test sequence to include new cases.</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8632/files#diff-7ff815b68943f08bef79f083c09e55ca8c18db8e25033034b12fa31f1d43dab4">+79/-2</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
</details>
___