Finish preliminary token auth method

This commit is contained in:
Tuan Dang
2024-07-02 15:05:57 -07:00
parent 661e5ec462
commit 93be4095c0
25 changed files with 1336 additions and 17 deletions
+18 -1
View File
@@ -8,6 +8,7 @@ import {
IdentityAzureAuth,
IdentityGcpAuth,
IdentityKubernetesAuth,
IdentityTokenAuth,
IdentityUniversalAuth} from "./types";
export const identitiesKeys = {
@@ -19,7 +20,8 @@ export const identitiesKeys = {
[{ identityId }, "identity-kubernetes-auth"] as const,
getIdentityGcpAuth: (identityId: string) => [{ identityId }, "identity-gcp-auth"] as const,
getIdentityAwsAuth: (identityId: string) => [{ identityId }, "identity-aws-auth"] as const,
getIdentityAzureAuth: (identityId: string) => [{ identityId }, "identity-azure-auth"] as const
getIdentityAzureAuth: (identityId: string) => [{ identityId }, "identity-azure-auth"] as const,
getIdentityTokenAuth: (identityId: string) => [{ identityId }, "identity-token-auth"] as const
};
export const useGetIdentityUniversalAuth = (identityId: string) => {
@@ -111,3 +113,18 @@ export const useGetIdentityKubernetesAuth = (identityId: string) => {
}
});
};
export const useGetIdentityTokenAuth = (identityId: string) => {
return useQuery({
enabled: Boolean(identityId),
queryKey: identitiesKeys.getIdentityTokenAuth(identityId),
queryFn: async () => {
const {
data: { identityTokenAuth }
} = await apiRequest.get<{ identityTokenAuth: IdentityTokenAuth }>(
`/api/v1/auth/token-auth/identities/${identityId}`
);
return identityTokenAuth;
}
});
};