Skip to content

Gateway: fix device identity required despite dangerouslyDisableDeviceAuth=true#29960

Open
alexyyyander wants to merge 7 commits intoopenclaw:mainfrom
alexyyyander:fix/29801-dangerously-disable-device-auth
Open

Gateway: fix device identity required despite dangerouslyDisableDeviceAuth=true#29960
alexyyyander wants to merge 7 commits intoopenclaw:mainfrom
alexyyyander:fix/29801-dangerously-disable-device-auth

Conversation

@alexyyyander
Copy link
Copy Markdown
Contributor

Summary

When gateway.controlUi.dangerouslyDisableDeviceAuth=true is set, the Gateway was still requiring device identity if there was no shared auth (token/password) present.

Root Cause

The evaluateMissingDeviceIdentity() function in connect-policy.ts didn't check the allowBypass flag early enough. It fell through to roleCanSkipDeviceIdentity() which requires sharedAuthOk=true, but when there's no token/password, sharedAuthOk is false, causing the connection to be rejected with "device identity required" even though device auth was supposed to be disabled.

Fix

Added an early check for controlUiAuthPolicy.allowBypass at the beginning of evaluateMissingDeviceIdentity(), which returns 'allow' immediately when device auth is disabled, regardless of whether shared auth is present.

Changes

  • src/gateway/server/ws-connection/connect-policy.ts: Added early return when allowBypass is true
  • src/gateway/server/ws-connection/connect-policy.test.ts: Added test coverage for the scenario

Fixes #29801

The secondary window was defaulting to 24 hours (86400 seconds),
causing the status to show 'Day' instead of 'Week' for users
with weekly usage limits when the API doesn't return the limit.

Changed default to 604800 seconds (168 hours = 1 week) since
Codex typically has weekly secondary windows.
Previously, detectContentType() checked for MP4 magic bytes (ftyp at
bytes 4-7) before the M4A-specific check, causing LINE voice
messages (M4A/AAC-LC in MPEG-4 container) to be misclassified as
video/mp4 instead of audio/mp4.

This fix checks the ftyp sub-brand at bytes 8-11 to distinguish:
- M4A / M4B (audio) -> returns audio/mp4
- isom/mp42 (video) -> returns video/mp4

Fixes openclaw#29751
- Show days (e.g., '2d', '3d') for multi-day windows between 24-167 hours
- 24 hours = 'Day', 168+ hours = 'Week'
- Previously all windows >= 24 hours showed as 'Day', which was confusing for multi-day periods
Fix issue openclaw#29886 where isolated sessions (cron/subagents) could not
access built-in provider env vars from openclaw.json.

The issue was that config env vars (like OPENAI_API_KEY, ANTHROPIC_API_KEY)
configured in openclaw.json were not being applied to process.env when
running isolated cron sessions. This fix ensures applyConfigEnvVars is
called at the start of runCronIsolatedAgentTurn to ensure these env
vars are available when resolving API keys for built-in providers.
The hardcoded system prompt instructed agents to use memory_search + memory_get
to pull only needed lines from memory files, which conflicts with AGENTS.md
that instructs agents to read entire memory files directly.

This conflict caused confusion for agents deciding which instructions to follow.

Fixes openclaw#29772
Fixes openclaw#29772 - Hardcoded system prompt conflicts with AGENTS.md

The AGENTS.md template instructed agents to read memory files directly,
while the system prompt instructed to use memory_search/memory_get tools
for memory context. This caused conflicting guidance.

Changes:
- Update AGENTS.md template to use memory_search/memory_get for memory
- Keep reading SOUL.md and USER.md directly (identity files)
- Update AGENTS.default.md similarly for consistency
…eAuth=true

When gateway.controlUi.dangerouslyDisableDeviceAuth=true is set, the Gateway
was still requiring device identity if there was no shared auth (token/password)
present. This was because evaluateMissingDeviceIdentity() didn't check the
allowBypass flag early enough - it fell through to roleCanSkipDeviceIdentity()
which requires sharedAuthOk=true.

Fix by adding an early check for controlUiAuthPolicy.allowBypass at the
beginning of evaluateMissingDeviceIdentity(), which returns 'allow' immediately
when device auth is disabled, regardless of whether shared auth is present.

Also adds test coverage for this scenario.

Fixes openclaw#29801
@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Feb 28, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 735297d3a9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

"## Memory Recall",
"Before answering anything about prior work, decisions, dates, people, preferences, or todos: run memory_search on MEMORY.md + memory/*.md; then use memory_get to pull only the needed lines. If low confidence after search, say you checked.",
];
const lines = ["## Memory Recall"];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reinstate memory lookup instruction in system prompt

The Memory Recall section now only emits a heading plus citation formatting guidance, but no longer tells the model to run memory_search/memory_get before answering questions about prior work or preferences. In sessions where memory tools are available, this regression makes it much more likely the agent responds from stale model context instead of retrieved notes, reducing answer accuracy for history-dependent queries.

Useful? React with 👍 / 👎.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

Fixes device identity requirement bug when device auth is set to bypass mode by adding an early check in the evaluateMissingDeviceIdentity() function. The fix correctly handles cases where device auth is disabled but no shared authentication is present.

Key changes:

Critical issue found: Comment corruption on line 94 of connect-policy.ts must be fixed before merge

Confidence Score: 3/5

  • Safe to merge after fixing the corrupted comment on line 94
  • The core logic fix is correct and well-tested with comprehensive coverage. However, there's a critical syntax issue (corrupted comment) that must be fixed before merging. The unrelated changes in the PR are all correct and safe. Score reflects the need to address the comment corruption before merge.
  • Pay attention to src/gateway/server/ws-connection/connect-policy.ts - fix the corrupted comment on line 94

Last reviewed commit: 735297d

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

// (needed for device identity) is unavailable in insecure HTTP contexts.
// Remote connections are still rejected to preserve the MitM protection
// that the security fix (#20684) intended.
// that the security fix (#20684) (!params.controlUi intended.
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.

comment corrupted - extra text (!params.controlUi inserted

Suggested change
// that the security fix (#20684) (!params.controlUi intended.
// that the security fix (#20684) intended.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/server/ws-connection/connect-policy.ts
Line: 94

Comment:
comment corrupted - extra text `(!params.controlUi` inserted

```suggestion
    // that the security fix (#20684) intended.
```

How can I resolve this? If you propose a fix, please make it concise.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 6, 2026
@RepairYourTech
Copy link
Copy Markdown

is this being worked on ?

@openclaw-barnacle openclaw-barnacle bot removed the stale Marked as stale due to inactivity label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: device identity required

3 participants