Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions setting/system_setting/passkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ func GetPasskeySettings() *PasskeySettings {
defaultPasskeySettings.RPID = serverAddr
}
}
if defaultPasskeySettings.Origins == "" || defaultPasskeySettings.Origins == "[]" {
defaultPasskeySettings.Origins = ServerAddress
}
Comment on lines +45 to +47

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

LGTM! Origins defaulting logic aligns with frontend guidance.

The logic correctly defaults Origins to ServerAddress when empty or when set to the literal string "[]". This matches the updated frontend text stating "为空则默认使用服务器地址" (defaults to server address when empty).

Verify that ServerAddress is properly validated elsewhere to ensure it contains the protocol (https://) as required by the WebAuthn spec and indicated in the UI text. Run this script to check how ServerAddress is initialized and validated:


🏁 Script executed:

#!/bin/bash
# Description: Verify ServerAddress initialization and validation

# Search for ServerAddress assignment and validation
rg -nP -C3 'ServerAddress\s*=' --type=go

# Search for any validation of ServerAddress format
rg -nP -C3 '(http://|https://).*ServerAddress|ServerAddress.*(http://|https://)' --type=go

Length of output: 2869


Enforce HTTPS scheme for ServerAddress
Add validation when setting ServerAddress (e.g., in model/option.go at the “ServerAddress” case) or before deriving the RPID (passkey.go:35-40) to reject or normalize any value that doesn’t start with “https://”, ensuring origins always comply with WebAuthn’s HTTPS requirement.

🤖 Prompt for AI Agents
In setting/system_setting/passkey.go around lines 45 to 47 (and the
ServerAddress handling in model/option.go at the “ServerAddress” case), enforce
that ServerAddress uses the HTTPS scheme by validating the value before using it
to derive origins/RPID: if the value does not start with "https://" either
reject it (return an error) or normalize it by prepending "https://" after
ensuring it is a valid URL; perform the check where ServerAddress is set
(model/option.go) or immediately before deriving RPID in passkey.go (lines
~35-40) so origins are always HTTPS-compliant, and surface an explicit
validation error if the scheme is not HTTPS rather than silently accepting or
using non-HTTPS values.

return &defaultPasskeySettings
}
4 changes: 2 additions & 2 deletions web/src/components/settings/SystemSetting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ const SystemSetting = () => {
field="['passkey.rp_id']"
label={t('网站域名标识')}
placeholder={t('例如:example.com')}
extraText={t('留空自动使用当前域名')}
extraText={t('留空则默认使用服务器地址,注意不能携带http://或者https://')}
/>
</Col>
</Row>
Expand Down Expand Up @@ -1111,7 +1111,7 @@ const SystemSetting = () => {
field="['passkey.origins']"
label={t('允许的 Origins')}
placeholder={t('填写带https的域名,逗号分隔')}
extraText={t('空的话则不限制 Origin,多个 Origin 用逗号分隔')}
extraText={t('为空则默认使用服务器地址,多个 Origin 用逗号分隔,例如 https://newapi.pro,https://newapi.com ,注意不能携带[],需使用https')}
/>
</Col>
</Row>
Expand Down