chore: oidc first

This commit is contained in:
xiaojunnuo
2025-11-26 07:34:42 +08:00
parent b4c362da37
commit 5a148aa3b9
12 changed files with 107 additions and 1586 deletions

View File

@@ -1,7 +1,8 @@
import { request } from "/src/api/service";
import { RequestHandleReq } from "/@/components/plugins/lib";
import { AddonTypeDefines } from "./types";
export function createAddonApi(opts: { from: any; addonType: string }) {
export function createAddonApi(opts: { from: any; addonType: string } = { from: "user", addonType: "" }) {
let apiPrefix = "/addon";
if (opts.from === "sys") {
apiPrefix = "/sys/addon";
@@ -128,15 +129,6 @@ export function createAddonApi(opts: { from: any; addonType: string }) {
};
}
export const AddonTypeDefines = {
captcha: {
name: "captcha",
title: "验证码",
showDefault: false,
showTest: false,
},
};
export function getAddonTypeDefine(addonType: string) {
return AddonTypeDefines[addonType];
}

View File

@@ -20,7 +20,7 @@ import { addonProvide } from "/@/views/certd/addon/common";
export default defineComponent({
name: "AddonManager",
setup() {
const api = createAddonApi();
const api = createAddonApi({ from: "user", addonType: "" });
addonProvide(api);
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api } });

View File

@@ -0,0 +1,15 @@
export interface AddonTypeDefine {
name: string;
title: string;
showDefault: boolean;
showTest: boolean;
}
export const AddonTypeDefines: Record<string, AddonTypeDefine> = {
captcha: {
name: "captcha",
title: "验证码",
showDefault: false,
showTest: false,
},
};

View File

@@ -106,6 +106,7 @@
"nanoid": "^5.0.7",
"node-forge": "^1.3.1",
"nodemailer": "^6.9.16",
"openid-client": "^6.8.1",
"otplib": "^12.0.1",
"pg": "^8.12.0",
"psl": "^1.9.0",

View File

@@ -0,0 +1,30 @@
import { BaseController, Constants } from "@certd/lib-server";
import { ALL, Body, Controller, Get, Post, Provide, Query } from "@midwayjs/core";
/**
*/
@Provide()
@Controller('/api/connect')
export class LoginController extends BaseController {
@Get('/login', { summary: Constants.per.guest })
public async login(@Query(ALL) body: any) {
//构造登录url
return this.ok(1);
}
@Get('/callback', { summary: Constants.per.guest })
public async callback(@Query(ALL) body: any) {
//处理登录回调
return this.ok(1);
}
@Post('/bind', { summary: Constants.per.guest })
public async bind(@Body(ALL) body: any) {
const autoRegister = body.autoRegister || false;
const bindInfo = body.bind || {};
//处理登录回调
return this.ok(1);
}
}

View File

@@ -0,0 +1,24 @@
export interface OauthProvider {
buildLoginUrl: (params: { redirectUri: string }) => string;
handleCallback: (params: { code: string; redirectUri: string }) => Promise<{
accessToken: string;
refreshToken: string;
expiresIn: number;
idToken: string;
scope: string;
tokenType: string;
}>;
bind: (params: {
accessToken: string;
refreshToken: string;
expiresIn: number;
idToken: string;
scope: string;
tokenType: string;
bindInfo: any;
}) => Promise<{
success: boolean;
message: string;
}>;
}

1609
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff