← 返回
未分类

PKU Info Auth

PKU unified credential management CLI (统一凭据管理). Use this skill when the user or AI Agent needs to authenticate with PKU services, manage stored credentials,...
PKU 统一凭据管理 CLI(统一凭据管理)。当用户或 AI Agent 需要对 PKU服务进行身份验证或管理已存储的凭据时使用此技能。
wjsoj
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 412
下载
💾 0
安装
1
版本
#auth#cli#credential#keyring#latest#pku#rust

概述

Info-Auth - PKU 统一凭据管理 CLI

Secure credential management for all PKU IAAA-based CLI tools. Allows AI Agents to trigger login flows without ever seeing passwords.

Why This Exists

AI Agents (like OpenClaw/Claude Code) cannot and should not handle user passwords directly. This tool lets users store credentials once in the OS keyring, then all CLI tools auto-authenticate from the keyring.

Architecture

  • Crate location: crates/info-auth/
  • Backend: OS keyring via keyring crate
  • Linux: D-Bus Secret Service (GNOME Keyring / KDE Wallet)
  • macOS: Apple Keychain
  • Windows: Windows Credential Manager
  • Keyring service name: info-pku

CLI Commands

CommandAliasFunction
--------------------------
storesaveInteractively input and store credentials to OS keyring
statusShow credential storage status (never shows password)
checkShow session status for ALL services (treehole/course/campuscard/elective)
clearRemove credentials from OS keyring

Credential Resolution Order

When any CLI tool runs login -p, credentials are resolved in this order:

  1. OS Keyring — stored via info-auth store (recommended)
  2. Environment variablesPKU_USERNAME + PKU_PASSWORD (for CI/automation)
  3. Interactive prompt — fallback, asks for username/password via stdin

SMS verification codes follow a similar pattern:

  1. Environment variablePKU_SMS_CODE (Agent can set this after asking user)
  2. Interactive prompt — fallback

For AI Agents — Quick Start

First-time setup (user does this once manually)

info-auth store
# User enters username + password interactively
# Credentials stored in OS keyring, encrypted

Agent workflow

# 1. Check which services have valid sessions
info-auth check

# 2. Login to any service (auto-reads credentials from keyring)
treehole login -p
course login -p
campuscard login -p
elective login -p          # may need: --dual major / --dual minor

# 3. If SMS verification is needed (treehole first login):
#    Ask user for the code, then set env var:
PKU_SMS_CODE=123456 treehole login -p

# 4. Use the service
treehole list
course courses --all
campuscard info
elective show

Key rules for Agents

  • NEVER pass passwords as CLI arguments
  • NEVER try to read the keyring directly — use info-auth status to check
  • If info-auth check shows "未登录" or "会话已过期", run login -p
  • If login fails with "系统密钥链中未存储凭据", ask user to run info-auth store

Development Notes

  • All user-facing strings in Chinese
  • Error handling: anyhow::Result with .context("中文描述")
  • The store command requires password confirmation (enter twice)
  • keyring_has_credential() returns diagnostic info on failure for debugging

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 09:10 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Treehole

wjsoj
PKU树洞(北大树洞)是一款用Rust编写的匿名论坛CLI工具。在使用treehole crate、调试treehole命令、添加功能等场景下使用此技能。
★ 0 📥 419

PKU Info Spider

wjsoj
微信公众号文章爬虫 CLI 工具,使用 Rust 编写。适用于 info‑spider crate 的开发、调试爬虫命令等场景。
★ 0 📥 445

PKU Campus Card

wjsoj
PKU校园卡 CLI 工具,使用 Rust 编写。适用于处理 campuscard 工具库、调试校园卡命令、添加功能等场景。
★ 0 📥 438