Skip to content

fix(iflow): add signed headers for chat requests#120

Merged
Mirrowel merged 2 commits into
Mirrowel:devfrom
redzrush101:fix/iflow-cookie-auth-none-data
Feb 11, 2026
Merged

fix(iflow): add signed headers for chat requests#120
Mirrowel merged 2 commits into
Mirrowel:devfrom
redzrush101:fix/iflow-cookie-auth-none-data

Conversation

@redzrush101

@redzrush101 redzrush101 commented Feb 11, 2026

Copy link
Copy Markdown

Summary

  • Add iFlow signed headers (session-id, x-iflow-timestamp, x-iflow-signature) to match CLIProxyAPI request protocol.
  • Build iFlow request headers via one helper and keep better context for empty upstream error bodies.
  • Verified locally: the same iFlow credential now works and streams successfully in LLM-API-Key-Proxy curl tests.

Important

Add iFlow signed headers for chat requests and improve error handling in iflow_provider.py.

  • Headers:
    • Add iFlow signed headers (session-id, x-iflow-timestamp, x-iflow-signature) in iflow_provider.py to match CLIProxyAPI protocol.
    • Implement _create_iflow_signature() and _build_iflow_headers() to generate and include these headers.
  • Error Handling:
    • Improve handling of empty upstream error bodies in stream_handler() in iflow_provider.py by logging content-type.
  • Misc:
    • Change result.get("data", {}) to result.get("data") or {} in iflow_auth_base.py to handle None values.

This description was created by Ellipsis for 2265aa5. You can customize this summary. It will automatically update as commits are pushed.

mirrobot-agent[bot] and others added 2 commits February 7, 2026 05:57
@mirrobot-agent

Copy link
Copy Markdown
Contributor

I'm starting my review of the iFlow signed headers implementation. I'll be checking the signature logic and the new header construction to ensure it aligns with the protocol requirements.

mirrobot-agent[bot]
mirrobot-agent Bot previously approved these changes Feb 11, 2026

@mirrobot-agent mirrobot-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall Assessment

This PR successfully implements the signed header protocol for iFlow requests, bringing it in line with the CLIProxyAPI requirements. The addition of session tracking and HMAC signatures improves the robustness of the authentication layer. The code is well-structured, with header construction centralized and error handling improved for edge cases like empty response bodies.

Architectural Feedback

The centralization of header logic into _build_iflow_headers is a good architectural choice, making the chat_completion logic cleaner and easier to maintain.

Key Suggestions

  • Signature Robustness: Consider adding explicit validation for the api_key before generating signatures to provide clearer error messages if authentication details are missing.
  • Session ID Format: Verify if the session- prefix is strictly required by the upstream iFlow API.

Questions for the Author

  • Can you confirm if the session- prefix in the session-id header is standard for all iFlow integrations or specific to this one?

This review was generated by an AI assistant.


return payload

def _create_iflow_signature(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _create_iflow_signature method returns an empty string if api_key is missing. While this prevents a crash, sending an empty signature to the upstream API will likely result in a 401/403 anyway. Consider adding a check or logging a warning if this occurs during a request.


def _build_iflow_headers(self, api_key: str, stream: bool) -> Dict[str, str]:
"""Build iFlow request headers, including signed auth headers."""
session_id = f"session-{uuid.uuid4()}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the session- prefix in f"session-{uuid.uuid4()}" a requirement of the iFlow protocol? Just want to ensure the upstream expects this specific format rather than a raw UUID.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know I basically just copied what https://github.com/router-for-me/CLIProxyAPI does which is written in go which worked and this fixed the issue

raise ValueError("iFlow user info request not successful")

data = result.get("data", {})
data = result.get("data") or {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using .get("data") or {} is a solid improvement over .get("data", {}). This pattern correctly handles cases where the API returns an explicit null (None in Python), which would otherwise cause downstream errors when trying to access keys on a None object.

@redzrush101 redzrush101 changed the title fix(iflow): add signed headers for chat requests fix(iflow): add signed headers for chat requests and fix containerfiles Feb 11, 2026
@redzrush101 redzrush101 force-pushed the fix/iflow-cookie-auth-none-data branch from 555d025 to 2265aa5 Compare February 11, 2026 19:51
@redzrush101 redzrush101 changed the title fix(iflow): add signed headers for chat requests and fix containerfiles fix(iflow): add signed headers for chat requests Feb 11, 2026
@Mirrowel Mirrowel merged commit 66d8f68 into Mirrowel:dev Feb 11, 2026
4 of 5 checks passed
b3nw pushed a commit to b3nw/LLM-API-Key-Proxy that referenced this pull request May 31, 2026
…h-none-data

fix(iflow): add signed headers for chat requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants