mirror of
https://github.com/certd/certd.git
synced 2026-04-05 07:20:56 +08:00
chore: oidc first
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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 } });
|
||||
|
||||
|
||||
15
packages/ui/certd-client/src/views/certd/addon/types.ts
Normal file
15
packages/ui/certd-client/src/views/certd/addon/types.ts
Normal 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,
|
||||
},
|
||||
};
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
24
packages/ui/certd-server/src/plugins/plugin-oauth/api.ts
Normal file
24
packages/ui/certd-server/src/plugins/plugin-oauth/api.ts
Normal 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
1609
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user