feat(auth): support OpenAPI persistent credentials, auto-refresh, and Web login link generation (v0.8.10)

This commit is contained in:
gitea committed 2026-09-28 16:50:18 +08:00
1 parent 1d825269f4
commit 96c5a3f242
27 files changed
+2994 -583

No files matched your search

+20
View File
@@ -208,6 +208,26 @@ export function loadCorpConfigs(overrideDirs?: string[]): CorpConfig[] {
export function saveCorpConfig(config: CorpConfig, dir?: string): string {
const targetDir = dir || resolveWritableEnterprisesDir();
ensureDir(targetDir);
const candidatePath = join(targetDir, `${config.id}.json`);
if (!config.credentials?.appKey && existsSync(candidatePath)) {
try {
const existing = JSON.parse(readFileSync(candidatePath, "utf-8"));
const existingKey = existing?.credentials?.appKey || existing?.auth?.appKey;
const existingSec = existing?.credentials?.appSecurity || existing?.auth?.appSecurity;
if (existingKey && existingSec) {
config = {
...config,
credentials: {
...config.credentials,
appKey: existingKey,
appSecurity: existingSec,
},
};
}
} catch {
// ignore malformed existing file
}
}
const validated = CorpConfigSchema.parse(config);
const filePath = join(targetDir, `${validated.id}.json`);
writeFileSync(filePath, JSON.stringify(validated, null, 2), "utf-8");