Add trusted IP rules to ST V3

This commit is contained in:
Tuan Dang
2023-09-30 20:52:04 +01:00
parent cdf4440848
commit eb2f433f43
11 changed files with 404 additions and 205 deletions
@@ -87,12 +87,14 @@ export const useUpdateServiceTokenV3 = () => {
name,
isActive,
scopes,
trustedIps,
expiresIn
}) => {
const { data: { serviceTokenData } } = await apiRequest.patch(`/api/v3/service-token/${serviceTokenDataId}`, {
name,
isActive,
scopes,
trustedIps,
expiresIn
});
@@ -44,6 +44,13 @@ export type ServiceTokenV3Scope = {
secretPath: string;
};
export type ServiceTokenV3TrustedIp = {
_id: string;
ipAddress: string;
type: "ipv4" | "ipv6";
prefix?: number;
}
export type ServiceTokenDataV3 = {
_id: string;
name: string;
@@ -52,6 +59,7 @@ export type ServiceTokenDataV3 = {
lastUsed?: string;
usageCount: number;
scopes: ServiceTokenV3Scope[];
trustedIps: ServiceTokenV3TrustedIp[];
expiresAt?: string;
createdAt: string;
updatedAt: string;
@@ -62,6 +70,9 @@ export type CreateServiceTokenDataV3DTO = {
workspaceId: string;
publicKey: string;
scopes: ServiceTokenV3Scope[];
trustedIps: {
ipAddress: string;
}[];
expiresIn?: number;
encryptedKey: string;
nonce: string;
@@ -77,6 +88,9 @@ export type UpdateServiceTokenDataV3DTO = {
isActive?: boolean;
name?: string;
scopes?: ServiceTokenV3Scope[];
trustedIps?: {
ipAddress: string;
}[];
expiresIn?: number;
}