mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(api): implement advanced API key management with granular controls
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { GenerateToken } from "@/components/dashboard/settings/profile/generate-token";
|
||||
import { ShowApiKeys } from "@/components/dashboard/settings/api/show-api-keys";
|
||||
import { ProfileForm } from "@/components/dashboard/settings/profile/profile-form";
|
||||
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
|
||||
|
||||
@@ -19,7 +19,7 @@ const Page = () => {
|
||||
<div className="w-full">
|
||||
<div className="h-full rounded-xl max-w-5xl mx-auto flex flex-col gap-4">
|
||||
<ProfileForm />
|
||||
{(data?.canAccessToAPI || data?.role === "owner") && <GenerateToken />}
|
||||
{(data?.canAccessToAPI || data?.role === "owner") && <ShowApiKeys />}
|
||||
|
||||
{/* {isCloud && <RemoveSelfAccount />} */}
|
||||
</div>
|
||||
|
||||
@@ -30,7 +30,41 @@ const Home: NextPage = () => {
|
||||
|
||||
return (
|
||||
<div className="h-screen bg-white">
|
||||
<SwaggerUI spec={spec} />
|
||||
<SwaggerUI
|
||||
spec={spec}
|
||||
persistAuthorization={true}
|
||||
plugins={[
|
||||
{
|
||||
statePlugins: {
|
||||
auth: {
|
||||
wrapActions: {
|
||||
authorize: (ori: any) => (args: any) => {
|
||||
const result = ori(args);
|
||||
const apiKey = args?.apiKey?.value;
|
||||
if (apiKey) {
|
||||
localStorage.setItem("swagger_api_key", apiKey);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
logout: (ori: any) => (args: any) => {
|
||||
const result = ori(args);
|
||||
localStorage.removeItem("swagger_api_key");
|
||||
return result;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
]}
|
||||
requestInterceptor={(request: any) => {
|
||||
const apiKey = localStorage.getItem("swagger_api_key");
|
||||
if (apiKey) {
|
||||
request.headers = request.headers || {};
|
||||
request.headers["x-api-key"] = apiKey;
|
||||
}
|
||||
return request;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user