mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
### **User description**
We can use cookie to make requests for CLI command for the case enabled
SSO can't use username & password.
```
ZO_CLI_USER_COOKIE=""
```
For now only used for CLI command.
___
### **PR Type**
Enhancement
___
### **Description**
- Add cookie-based CLI authentication
- Fallback to basic auth when no cookie
- Introduce config `ZO_ROOT_USER_COOKIE`
___
### Diagram Walkthrough
```mermaid
flowchart LR
CFG["Config: add root_user_cookie"] -- "read env ZO_ROOT_USER_COOKIE" --> CLI["CLI HTTP request builder"]
CLI -- "cookie present" --> HDR["Set Cookie header"]
CLI -- "cookie empty" --> BASIC["Use basic_auth(email,password)"]
```
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>http.rs</strong><dd><code>Add Cookie header auth with
fallback</code>
</dd></summary>
<hr>
src/cli/basic/http.rs
<ul><li>Read <code>root_user_cookie</code> from config.<br> <li> Use
Cookie header when provided.<br> <li> Fallback to basic auth if cookie
empty.<br> <li> Preserve JSON body handling.</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8189/files#diff-790b7780a51e8eecd4754b623af8d15ad87baaaf29455ba646e2e410f83f5498">+7/-1</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>config.rs</strong><dd><code>Support cookie env in auth
config</code>
</dd></summary>
<hr>
src/config/src/config.rs
<ul><li>Add <code>root_user_cookie</code> to <code>Auth</code>
struct.<br> <li> Map to env var <code>ZO_ROOT_USER_COOKIE</code>.</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8189/files#diff-9aeee4a74c0520daa40f9b81c7016f5b6b3254375b968dd7598e745630980d62">+2/-0</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
</details>
___
---------
Co-authored-by: Ashish Kolhe <ashish.j.kolhe@gmail.com>