add tenancy OCID requirement

This commit is contained in:
x032205
2025-05-09 22:33:02 -04:00
parent 578a0d7d93
commit 5742fc648b
12 changed files with 59 additions and 1 deletions
@@ -461,6 +461,7 @@ export const useAddIdentityOciAuth = () => {
return useMutation<IdentityOciAuth, object, AddIdentityOciAuthDTO>({
mutationFn: async ({
identityId,
tenancyOcid,
allowedUsernames,
accessTokenTTL,
accessTokenMaxTTL,
@@ -472,6 +473,7 @@ export const useAddIdentityOciAuth = () => {
} = await apiRequest.post<{ identityOciAuth: IdentityOciAuth }>(
`/api/v1/auth/oci-auth/identities/${identityId}`,
{
tenancyOcid,
allowedUsernames,
accessTokenTTL,
accessTokenMaxTTL,
@@ -497,6 +499,7 @@ export const useUpdateIdentityOciAuth = () => {
return useMutation<IdentityOciAuth, object, UpdateIdentityOciAuthDTO>({
mutationFn: async ({
identityId,
tenancyOcid,
allowedUsernames,
accessTokenTTL,
accessTokenMaxTTL,
@@ -508,6 +511,7 @@ export const useUpdateIdentityOciAuth = () => {
} = await apiRequest.patch<{ identityOciAuth: IdentityOciAuth }>(
`/api/v1/auth/oci-auth/identities/${identityId}`,
{
tenancyOcid,
allowedUsernames,
accessTokenTTL,
accessTokenMaxTTL,
@@ -293,6 +293,7 @@ export type DeleteIdentityAwsAuthDTO = {
export type IdentityOciAuth = {
identityId: string;
type: "iam";
tenancyOcid: string;
allowedUsernames: string;
accessTokenTTL: number;
accessTokenMaxTTL: number;
@@ -303,6 +304,7 @@ export type IdentityOciAuth = {
export type AddIdentityOciAuthDTO = {
organizationId: string;
identityId: string;
tenancyOcid: string;
allowedUsernames: string;
accessTokenTTL: number;
accessTokenMaxTTL: number;
@@ -315,6 +317,7 @@ export type AddIdentityOciAuthDTO = {
export type UpdateIdentityOciAuthDTO = {
organizationId: string;
identityId: string;
tenancyOcid?: string;
allowedUsernames?: string;
accessTokenTTL?: number;
accessTokenMaxTTL?: number;
@@ -29,6 +29,7 @@ import { IdentityFormTab } from "./types";
const schema = z
.object({
tenancyOcid: z.string().trim().min(1, "Tenancy OCID is required."),
allowedUsernames: z.string(),
accessTokenTTL: z
.string()
@@ -90,6 +91,7 @@ export const IdentityOciAuthForm = ({
} = useForm<FormData>({
resolver: zodResolver(schema),
defaultValues: {
tenancyOcid: "",
allowedUsernames: "",
accessTokenTTL: "2592000",
accessTokenMaxTTL: "2592000",
@@ -107,6 +109,7 @@ export const IdentityOciAuthForm = ({
useEffect(() => {
if (data) {
reset({
tenancyOcid: data.tenancyOcid,
allowedUsernames: data.allowedUsernames,
accessTokenTTL: String(data.accessTokenTTL),
accessTokenMaxTTL: String(data.accessTokenMaxTTL),
@@ -121,6 +124,7 @@ export const IdentityOciAuthForm = ({
});
} else {
reset({
tenancyOcid: "",
allowedUsernames: "",
accessTokenTTL: "2592000",
accessTokenMaxTTL: "2592000",
@@ -131,6 +135,7 @@ export const IdentityOciAuthForm = ({
}, [data]);
const onFormSubmit = async ({
tenancyOcid,
allowedUsernames,
accessTokenTTL,
accessTokenMaxTTL,
@@ -143,6 +148,7 @@ export const IdentityOciAuthForm = ({
if (data) {
await updateMutateAsync({
organizationId: orgId,
tenancyOcid,
allowedUsernames,
identityId,
accessTokenTTL: Number(accessTokenTTL),
@@ -154,6 +160,7 @@ export const IdentityOciAuthForm = ({
await addMutateAsync({
organizationId: orgId,
identityId,
tenancyOcid,
allowedUsernames: allowedUsernames || "",
accessTokenTTL: Number(accessTokenTTL),
accessTokenMaxTTL: Number(accessTokenMaxTTL),
@@ -194,12 +201,22 @@ export const IdentityOciAuthForm = ({
<Tab value={IdentityFormTab.Advanced}>Advanced</Tab>
</TabList>
<TabPanel value={IdentityFormTab.Configuration}>
<Controller
control={control}
name="tenancyOcid"
render={({ field, fieldState: { error } }) => (
<FormControl label="Tenancy OCID" isError={Boolean(error)} errorText={error?.message}>
<Input {...field} placeholder="ocid1.tenancy.oc1..example" />
</FormControl>
)}
/>
<Controller
control={control}
name="allowedUsernames"
render={({ field, fieldState: { error } }) => (
<FormControl
label="Allowed Usernames"
isOptional
isError={Boolean(error)}
errorText={error?.message}
>
@@ -59,6 +59,9 @@ export const ViewIdentityOciAuthContent = ({
<IdentityAuthFieldDisplay label="Access Token Trusted IPs">
{data.accessTokenTrustedIps.map((ip) => ip.ipAddress).join(", ")}
</IdentityAuthFieldDisplay>
<IdentityAuthFieldDisplay className="col-span-2" label="Tenancy OCID">
{data.tenancyOcid}
</IdentityAuthFieldDisplay>
<IdentityAuthFieldDisplay className="col-span-2" label="Allowed Usernames">
{data.allowedUsernames
?.split(",")