05270817
This commit is contained in:
parent
fb87663201
commit
8aa86268de
|
@ -16,17 +16,17 @@ async function getClients() {
|
|||
: [];
|
||||
|
||||
// 管理后台client,通过环境变量读取
|
||||
const adminClient = {
|
||||
const defaultClient = {
|
||||
client_id: process.env.OIDC_CLIENT_ID || 'admin-client',
|
||||
client_secret: process.env.OIDC_CLIENT_SECRET || 'admin-secret',
|
||||
grant_types: ['authorization_code', 'refresh_token'],
|
||||
redirect_uris: [process.env.OIDC_REDIRECT_URI || 'http://localhost:3000/admin/callback'],
|
||||
redirect_uris: [process.env.OIDC_REDIRECT_URI || 'http://localhost:3000/callback'],
|
||||
response_types: ['code'],
|
||||
scope: 'openid email profile',
|
||||
};
|
||||
|
||||
// 检查是否与数据库client_id重复
|
||||
const allClients = [adminClient, ...dbClientList.filter(c => c.client_id !== adminClient.client_id)];
|
||||
const allClients = [defaultClient, ...dbClientList.filter(c => c.client_id !== defaultClient.client_id)];
|
||||
|
||||
return allClients;
|
||||
}
|
||||
|
@ -50,7 +50,29 @@ const config: Configuration = {
|
|||
cookies: {
|
||||
keys: [OIDC_COOKIE_KEY],
|
||||
},
|
||||
jwks: [],
|
||||
jwks: {
|
||||
keys: [
|
||||
{
|
||||
d: 'VEZOsY07JTFzGTqv6cC2Y32vsfChind2I_TTuvV225_-0zrSej3XLRg8iE_u0-3GSgiGi4WImmTwmEgLo4Qp3uEcxCYbt4NMJC7fwT2i3dfRZjtZ4yJwFl0SIj8TgfQ8ptwZbFZUlcHGXZIr4nL8GXyQT0CK8wy4COfmymHrrUoyfZA154ql_OsoiupSUCRcKVvZj2JHL2KILsq_sh_l7g2dqAN8D7jYfJ58MkqlknBMa2-zi5I0-1JUOwztVNml_zGrp27UbEU60RqV3GHjoqwI6m01U7K0a8Q_SQAKYGqgepbAYOA-P4_TLl5KC4-WWBZu_rVfwgSENwWNEhw8oQ',
|
||||
dp: 'E1Y-SN4bQqX7kP-bNgZ_gEv-pixJ5F_EGocHKfS56jtzRqQdTurrk4jIVpI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KHQ4waE26CzoXx-JNOgN0iqJMN6C4_XJEX-cSvCZDf4rh7xpXN6SGLVd5ibIyDJi7bbi5EQ5AXjazPbLBjRthcGXsIuZ3AtQyR0CEWNSdM7EyM5TRdyZQ9kftfz9nI03guW3iKKASETqX2vh0Z8XRjyU',
|
||||
use: 'sig',
|
||||
}, {
|
||||
crv: 'P-256',
|
||||
d: 'K9xfPv773dZR22TVUB80xouzdF7qCg5cWjPjkHyv7Ws',
|
||||
kty: 'EC',
|
||||
use: 'sig',
|
||||
x: 'FWZ9rSkLt6Dx9E3pxLybhdM6xgR5obGsj5_pqmnz5J4',
|
||||
y: '_n8G69C-A2Xl4xUW2lF0i8ZGZnk_KPYrhv4GbTGu5G4',
|
||||
},
|
||||
],
|
||||
},
|
||||
ttl: {
|
||||
AccessToken: 3600,
|
||||
AuthorizationCode: 600,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Provider } from 'oidc-provider';
|
||||
import config from './config';
|
||||
|
||||
const oidc = new Provider('http://localhost:4000', config);
|
||||
const oidc = new Provider('http://localhost:3000', config);
|
||||
|
||||
export default oidc;
|
|
@ -1,5 +1,6 @@
|
|||
import { z } from 'zod'
|
||||
import { initTRPC } from '@trpc/server'
|
||||
import { userRouter } from './user/user.trpc'
|
||||
|
||||
const t = initTRPC.create()
|
||||
|
||||
|
@ -7,9 +8,7 @@ export const publicProcedure = t.procedure
|
|||
export const router = t.router
|
||||
|
||||
export const appRouter = router({
|
||||
hello: publicProcedure.input(z.string().nullish()).query(({ input }) => {
|
||||
return `Hello ${input ?? 'World'}!`
|
||||
}),
|
||||
user: userRouter
|
||||
})
|
||||
|
||||
export type AppRouter = typeof appRouter
|
|
@ -1,17 +1,17 @@
|
|||
import { Hono } from "hono";
|
||||
import { createUser, searchUser } from "./userindex";
|
||||
import { createUser, searchUser } from "./user.index";
|
||||
|
||||
const userRoute = new Hono();
|
||||
const userRest = new Hono();
|
||||
|
||||
userRoute.post('/', async (c) => {
|
||||
userRest.post('/', async (c) => {
|
||||
const user = await c.req.json();
|
||||
const result = await createUser(user);
|
||||
return c.json(result);
|
||||
});
|
||||
|
||||
userRoute.get('/search', async (c) => {
|
||||
userRest.get('/search', async (c) => {
|
||||
const q = c.req.query('q') || '';
|
||||
const result = await searchUser(q);
|
||||
return c.json(result.hits.hits);
|
||||
});
|
||||
export default userRoute;
|
||||
export default userRest;
|
|
@ -1,5 +1,6 @@
|
|||
export default async function Home() {
|
||||
|
||||
return <div>
|
||||
|
||||
123
|
||||
</div>;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ export default function QueryProvider({ children }) {
|
|||
const accessToken = '';
|
||||
|
||||
// 使用Next.js环境变量
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000';
|
||||
|
||||
// Set the default query options including staleTime.
|
||||
const [queryClient] = useState(
|
||||
|
|
Loading…
Reference in New Issue