Skip to content

feat: silent CAS auto-login and otpauth:// TOTP parsing - #3

Closed
Yjiutong wants to merge 1 commit into
Conduit-Club:mainfrom
Yjiutong:codex/silent-cas-login-and-otpauth-totp
Closed

Yjiutong wants to merge 1 commit into
Conduit-Club:mainfrom
Yjiutong:codex/silent-cas-login-and-otpauth-totp

Conversation

@Yjiutong

@Yjiutong Yjiutong commented Nov 6, 2026 •

Copy link
Copy Markdown

本次递交改进了什么

1. CAS 静默自动登录

  • SsoLoginWebView 在有保存凭据时隐藏窗口,自动填充真实 CAS 表单(#fm1Input 内的 #username/#password),等待 RSA 公钥加载完成后点击可见的登录按钮,避免误触隐藏表单。
  • 仅把携带 ticket 的 /passport/v1/auth/cas 回调视为成功。
  • 仅在账号密码错误、页面要求验证码/MFA、加载失败或等待超时等异常时重新显示内嵌窗口,供手动完成验证;其余情况全程静默。
  • AuthDialogCoordinator 统一驱动「隐藏 → 异常回退」流程;配置引导与设置窗口现可保存 CAS 学工号/安全手机(账号)和密码。
  • QSettings 密码字段统一用 fromBase64/toBase64,修复中文可能存在的乱码。

2. TOTP 密钥支持 otpauth:// 链接自动解析

  • 新增 SettingsProfileLoader::normalizeTotpSecret():识别 otpauth:// 前缀并用 QUrl/QUrlQuery 提取 secret 参数;普通明文密钥原样保留(仅去除首尾空格)。
  • 该归一化在「读取配置」和「设置窗口 / 配置引导保存」两处均生效,保证 config.ini 中最终只存裸密钥。
  • UI 占位提示同步更新,告知用户可直接粘贴认证器导出的 otpauth:// 链接。

3. 文档与测试

  • docs/ADVANCED_USAGE.md 更新静默登录说明。
  • 新增 normalizeTotpSecret 单元测试(使用占位密钥,不含任何真实凭据)。

验证

  • Release 主程序编译通过;settingsprofileloader_test 运行通过(exit 0),此前 CTest 全集 18/18 通过。
  • 部署目录 SHOUConnect-local 已补齐核心 zju-connect.exe 并 windeployqt 更新,可正常启动。

注意(需人工验证,构建通过不能替代)

  • 真实 CAS/TOTP 登录需用户账号参与,且需在「配置引导/设置」中保存凭据后实测静默效果;无凭据时仍走手动回退。

补充:个人人工测试通过,仍需更多样本验证可靠性

Silent CAS login:
- SsoLoginWebView hides the window when credentials are saved, fills the
  real CAS form (#username/#password inside #fm1Input), waits for the RSA
  public key, then clicks the visible submit button.
- Success is only the /passport/v1/auth/cas callback carrying a ticket.
- The window is re-shown only on failure, captcha/MFA prompt, load error,
  or timeout, so manual verification happens solely on exception.
- AuthDialogCoordinator drives the hidden-then-fallback flow; config guide
  and settings now collect CAS work/phone account and password.
- QSettings password fields use fromBase64/toBase64 to avoid mojibake.

TOTP parsing:
- SettingsProfileLoader::normalizeTotpSecret extracts the raw secret from an
  otpauth:// URL (authenticator export link), passing through plain secrets.
  Applied on load and on save in both settings and config guide, so the
  stored value is always the bare secret.

Docs/tests:
- Document the deploy requirement (bare build/Release exe needs Qt libs)
  and update silent-login wording; add normalizeTotpSecret unit test.

No build artifacts (build/, SHOUConnect-local/, build-tests/) are committed;
they remain gitignored. Real credentials are never written to the repo.
@Yjiutong
Yjiutong force-pushed the codex/silent-cas-login-and-otpauth-totp branch from fd2cc05 to de5e1b2 Compare November 6, 2026 17:59
@Yjiutong Yjiutong closed this Nov 6, 2026
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.

1 participant