Skip to content

feat: add FIDO WebAuthn login support#133

Open
nkanf-dev wants to merge 5 commits into
BenderBlog:mainfrom
nkanf-dev:feat/support-fido
Open

feat: add FIDO WebAuthn login support#133
nkanf-dev wants to merge 5 commits into
BenderBlog:mainfrom
nkanf-dev:feat/support-fido

Conversation

@nkanf-dev
Copy link
Copy Markdown

Changes

  • FIDO registration: generate P-256 key pair, build CBOR attestation, register with IDS server via /personalInfo/accountSecurity endpoints
  • FIDO login: assertion-based authentication via /authserver/startAssertion and form submission, bypassing password + captcha flow
  • IDS recheck: secondary verification (password + captcha) for sensitive operations like FIDO registration and device deletion
  • Login window: FIDO quick login button, post-login prompt to register FIDO as backup login method
  • Settings: FIDO registration/deletion UI with server-side credential cleanup
  • i18n: FIDO-related strings in zh_CN, en_US, zh_TW
  • Dependencies: added pointycastle, cbor, device_info_plus

FIDO认证器注册
image

优先使用FIDO凭据进行登录
image

FIDO登录流程
image

- FIDO registration: generate P-256 key pair, build CBOR attestation,
  register with IDS server via /personalInfo/accountSecurity endpoints
- FIDO login: assertion-based authentication via /authserver/startAssertion
  and form submission, bypassing password + captcha flow
- IDS recheck: secondary verification (password + captcha) for sensitive
  operations like FIDO registration and device deletion
- Login window: FIDO quick login button, post-login prompt to register
  FIDO as backup login method
- Settings: FIDO registration/deletion UI with server-side credential cleanup
- i18n: FIDO-related strings in zh_CN, en_US, zh_TW
- Dependencies: added pointycastle, cbor, device_info_plus
Copilot AI review requested due to automatic review settings May 13, 2026 03:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds FIDO/WebAuthn-based authentication support for the Xidian IDS flow, including credential registration, assertion-based login, and a secondary “recheck” verification step for sensitive personalInfo operations.

Changes:

  • Added a FIDO session implementation to register a P-256 credential and perform assertion-based login against IDS endpoints.
  • Introduced an IDS recheck service (password + image captcha) and shared AES utility used by both recheck and slider-captcha payload encryption.
  • Updated login/settings UI and i18n strings to expose FIDO quick login, registration prompts, and credential deletion/cleanup.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pubspec.yaml Adds cbor dependency needed for WebAuthn attestation encoding.
pubspec.lock Locks cbor (and new transitive hex) versions for the build.
lib/repository/xidian_ids/ids_session.dart Attempts FIDO login first (when enabled) before falling back to password flow.
lib/repository/xidian_ids/ids_recheck.dart Adds secondary verification logic for sensitive /personalInfo actions (captcha + encrypted password).
lib/repository/xidian_ids/ids_crypto.dart Centralizes IDS AES-CBC encryption logic shared across features.
lib/repository/xidian_ids/fido_session.dart Implements FIDO registration + assertion login, CBOR/COSE encoding, and key handling.
lib/repository/preference.dart Adds persisted fields for FIDO credential material and an enable flag.
lib/page/setting/setting.dart Adds settings UI/actions to register/delete FIDO and attempts server cleanup on logout/clear.
lib/page/login/login_window.dart Adds “FIDO Quick Login” button and post-login prompt to register FIDO.
lib/page/login/jc_captcha.dart Refactors slider captcha encryption to reuse IdsCrypto.
lib/page/login/image_captcha.dart Adds image captcha UI used by IDS recheck.
assets/flutter_i18n/zh_TW.yaml Adds FIDO-related UI strings (Traditional Chinese).
assets/flutter_i18n/zh_CN.yaml Adds FIDO-related UI strings (Simplified Chinese).
assets/flutter_i18n/en_US.yaml Adds FIDO-related UI strings (English).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/repository/xidian_ids/ids_recheck.dart Outdated
Comment thread lib/repository/xidian_ids/fido_session.dart
Comment on lines +227 to +230
await preference.setString(
preference.Preference.fidoPrivateKeyPem,
keyResult.privateKeyPem,
);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

先跳过,后期再说迁移到 https://github.com/xaldarof/encrypted-shared-preferences 的事项

Comment thread lib/repository/xidian_ids/fido_session.dart
Comment thread lib/page/login/login_window.dart
Comment thread lib/page/login/login_window.dart Outdated
Comment thread lib/page/login/image_captcha.dart

final String cookie;
Dio dio = Dio()..interceptors.add(logDioAdapter);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

这代码更改太大了

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.

这里因为这个二次验证的请求数据用了和那个滑块一样的加密。所以把这段加密的逻辑搬出去复用了。

Comment thread lib/repository/xidian_ids/fido_session.dart Outdated
Comment thread lib/repository/xidian_ids/fido_session.dart Outdated
// ---------------------------------------------------------------------------
// PEM / DER Helpers
// ---------------------------------------------------------------------------

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

一堆私有函数,头疼,需要按需简化,尤其是仅调用一次的那种

nkanf-dev added 4 commits May 13, 2026 14:18
- image_captcha.dart: replace hardcoded Chinese with FlutterI18n.translate
- login_window.dart: translate FIDO progress status keys
- fido_session.dart: change LoginFailedException to FidoException for
  consistent i18n wrapping
- setting.dart: translate "Updating data" toast
- i18n: add login.image_captcha.*, fido_process.*, setting.updating_data
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.

3 participants