Switch access token tracking to be persistent, add num uses, draft token renewal, update docs

This commit is contained in:
Tuan Dang
2023-12-07 00:11:16 +07:00
parent aafbe40c02
commit 69b57817d6
17 changed files with 481 additions and 209 deletions
@@ -34,14 +34,14 @@ export const useCreateMachineIdentityClientSecret = () => {
machineId,
description,
ttl,
usageLimit
numUsesLimit
}) => {
const { data } = await apiRequest.post(`/api/v1/machine-identities/${machineId}/client-secrets`, {
machineId,
description,
ttl,
usageLimit
numUsesLimit
});
return data;
@@ -80,7 +80,8 @@ export const useUpdateMachineIdentity = () => {
role,
clientSecretTrustedIps,
accessTokenTrustedIps,
accessTokenTTL
accessTokenTTL,
accessTokenNumUsesLimit
}) => {
const { data: { machineIdentity } } = await apiRequest.patch(`/api/v1/machine-identities/${machineId}`, {
@@ -89,6 +90,7 @@ export const useUpdateMachineIdentity = () => {
clientSecretTrustedIps,
accessTokenTrustedIps,
accessTokenTTL,
accessTokenNumUsesLimit
});
return machineIdentity;
@@ -12,10 +12,9 @@ export type MachineIdentity = {
clientId: string;
name: string;
organization: string;
isActive: boolean;
accessTokenTTL: number;
accessTokenLastUsed?: string;
accessTokenUsageCount: number;
accessTokenMaxTTL: number;
accessTokenNumUsesLimit: number;
clientSecretTrustedIps: MachineTrustedIp[];
accessTokenTrustedIps: MachineTrustedIp[];
createdAt: string;
@@ -25,7 +24,6 @@ export type MachineIdentity = {
export type MachineIdentityClientSecret = {
_id: string;
machineIdentity: string;
isActive: boolean;
description: string;
clientSecretPrefix: string;
clientSecretNumUses: number;
@@ -33,6 +31,7 @@ export type MachineIdentityClientSecret = {
clientSecretTTL: number;
createdAt: string;
updatedAt: string;
isClientSecretRevoked: boolean;
}
export type MachineMembershipOrg = {
@@ -66,13 +65,15 @@ export type CreateMachineIdentityDTO = {
ipAddress: string;
}[];
accessTokenTTL: number;
accessTokenMaxTTL: number;
accessTokenNumUsesLimit: number;
}
export type CreateMachineIdentityClientSecretDTO = {
machineId: string;
description?: string;
ttl?: number;
usageLimit?: number;
numUsesLimit?: number;
}
export type CreateMachineIdentityClientSecretRes = {
@@ -100,6 +101,8 @@ export type UpdateMachineIdentityDTO = {
ipAddress: string;
}[];
accessTokenTTL?: number;
accessTokenMaxTTL?: number;
accessTokenNumUsesLimit?: number;
}
export type DeleteMachineIdentityDTO = {