Skip to content

Commit

Permalink
Update certificate operations actions to include certificate request …
Browse files Browse the repository at this point in the history
…format parameter (#682)
  • Loading branch information
AbbyB97 committed May 9, 2024
1 parent 86af6b8 commit 1be106e
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Form as BootstrapForm, Button, ButtonGroup, FormFeedback, FormGroup, La
import { AttributeDescriptorModel } from 'types/attributes';
import { CertificateDetailResponseModel } from 'types/certificate';
import { CryptographicKeyPairResponseModel } from 'types/cryptographic-keys';
import { KeyType } from 'types/openapi';
import { CertificateRequestFormat, KeyType } from 'types/openapi';
import { mutators } from 'utils/attributes/attributeEditorMutators';
import { collectFormAttributes } from 'utils/attributes/attributes';

Expand Down Expand Up @@ -103,7 +103,8 @@ export default function CertificateRekeyDialog({ onCancel, certificate }: props)
raProfileUuid: certificate.raProfile.uuid,
authorityUuid: certificate.raProfile.authorityInstanceUuid,
rekey: {
pkcs10: fileContent ? fileContent : undefined,
request: fileContent ? fileContent : undefined,
format: CertificateRequestFormat.Pkcs10,
signatureAttributes: collectFormAttributes('signatureAttributes', signatureAttributeDescriptors, values),
keyUuid: values.key?.value.uuid || '',
tokenProfileUuid: values.tokenProfile?.value || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {
export default function CertificateRenewDialog({ onCancel, allowWithoutFile, onRenew }: Props) {
const dispatch = useDispatch();

const [fileContent, setFileContent] = useState('');
const [fileContent, setFileContent] = useState<string | undefined>();
const [uploadCsr, setUploadCsr] = useState(false);
const [certificate, setCertificate] = useState<CertificateDetailResponseModel | undefined>();

Expand Down
6 changes: 5 additions & 1 deletion src/components/_pages/certificates/detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { selectors as settingSelectors } from 'ducks/settings';
import {
CertificateState as CertStatus,
CertificateFormatEncoding,
CertificateRequestFormat,
CertificateRevocationReason,
CertificateValidationStatus,
} from '../../../../types/openapi';
Expand Down Expand Up @@ -478,7 +479,10 @@ export default function CertificateDetail() {
dispatch(
actions.renewCertificate({
uuid: certificate?.uuid || '',
renewRequest: { pkcs10: data.fileContent ? data.fileContent : undefined },
renewRequest: {
format: CertificateRequestFormat.Pkcs10,
request: data.fileContent,
},
raProfileUuid: certificate?.raProfile?.uuid || '',
authorityUuid: certificate?.raProfile?.authorityInstanceUuid || '',
}),
Expand Down
8 changes: 4 additions & 4 deletions src/components/_pages/certificates/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ import {
selectors as utilsCertificateRequestSelectors,
} from '../../../../ducks/utilsCertificateRequest';
import { CertificateDetailResponseModel } from '../../../../types/certificate';
import { Resource } from '../../../../types/openapi';
import { CertificateRequestFormat, Resource } from '../../../../types/openapi';
import CertificateAttributes from '../../../CertificateAttributes';
import FileUpload from '../../../Input/FileUpload/FileUpload';
import TabLayout from '../../../Layout/TabLayout';
import RenderRequestKey from './RenderRequestKey';

export interface FormValues {
raProfile: SingleValue<{ label: string; value: RaProfileResponseModel }> | null;
pkcs10: File | null;
format?: CertificateRequestFormat;
uploadCsr?: SingleValue<{ label: string; value: boolean }> | null;
tokenProfile?: SingleValue<{ label: string; value: TokenProfileResponseModel }> | null;
key?: SingleValue<{ label: string; value: CryptographicKeyPairResponseModel }> | null;
Expand Down Expand Up @@ -109,7 +109,8 @@ export default function CertificateForm() {
raProfileUuid: values.raProfile.value.uuid,
authorityUuid: values.raProfile.value.authorityInstanceUuid,
signRequest: {
pkcs10: fileContent,
format: CertificateRequestFormat.Pkcs10,
request: fileContent,
attributes,
csrAttributes: collectFormAttributes('csrAttributes', csrAttributeDescriptors, values),
signatureAttributes: collectFormAttributes('signatureAttributes', signatureAttributeDescriptors, values),
Expand Down Expand Up @@ -183,7 +184,6 @@ export default function CertificateForm() {
const defaultValues: FormValues = useMemo(
() => ({
raProfile: null,
pkcs10: null,
fileName: '',
contentType: '',
file: '',
Expand Down
2 changes: 1 addition & 1 deletion src/types/openapi/models/CertificateRequestFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

/**
* Certificate request format
* Certificate signing request format
* @export
* @enum {string}
*/
Expand Down
12 changes: 10 additions & 2 deletions src/types/openapi/models/ClientCertificateRekeyRequestDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

import type {
CertificateRequestFormat,
RequestAttributeDto,
} from './';

Expand All @@ -27,11 +28,16 @@ export interface ClientCertificateRekeyRequestDto {
*/
replaceInLocations?: boolean;
/**
* Certificate sign request (PKCS#10) encoded as Base64 string. If not provided, CSR attributes will be used
* Certificate signing request encoded as Base64 string. If not provided, CSR attributes will be used
* @type {string}
* @memberof ClientCertificateRekeyRequestDto
*/
pkcs10?: string;
request?: string;
/**
* @type {CertificateRequestFormat}
* @memberof ClientCertificateRekeyRequestDto
*/
format?: CertificateRequestFormat;
/**
* Key UUID
* @type {string}
Expand All @@ -51,3 +57,5 @@ export interface ClientCertificateRekeyRequestDto {
*/
signatureAttributes?: Array<RequestAttributeDto>;
}


15 changes: 13 additions & 2 deletions src/types/openapi/models/ClientCertificateRenewRequestDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* Do not edit the class manually.
*/

import type {
CertificateRequestFormat,
} from './';

/**
* @export
* @interface ClientCertificateRenewRequestDto
Expand All @@ -23,9 +27,16 @@ export interface ClientCertificateRenewRequestDto {
*/
replaceInLocations?: boolean;
/**
* Certificate sign request (PKCS#10) encoded as Base64 string. If not provided, Existing CSR will be used
* Certificate signing request encoded as Base64 string. If not provided, Existing CSR will be used
* @type {string}
* @memberof ClientCertificateRenewRequestDto
*/
pkcs10?: string;
request?: string;
/**
* @type {CertificateRequestFormat}
* @memberof ClientCertificateRenewRequestDto
*/
format?: CertificateRequestFormat;
}


12 changes: 10 additions & 2 deletions src/types/openapi/models/ClientCertificateRequestDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

import type {
CertificateRequestFormat,
RequestAttributeDto,
} from './';

Expand Down Expand Up @@ -45,11 +46,16 @@ export interface ClientCertificateRequestDto {
*/
signatureAttributes?: Array<RequestAttributeDto>;
/**
* Certificate sign request (PKCS#10) encoded as Base64 string
* Certificate signing request encoded as Base64 string
* @type {string}
* @memberof ClientCertificateRequestDto
*/
pkcs10?: string;
request?: string;
/**
* @type {CertificateRequestFormat}
* @memberof ClientCertificateRequestDto
*/
format?: CertificateRequestFormat;
/**
* Token Profile UUID. Required if CSR is not uploaded
* @type {string}
Expand All @@ -75,3 +81,5 @@ export interface ClientCertificateRequestDto {
*/
customAttributes?: Array<RequestAttributeDto>;
}


12 changes: 10 additions & 2 deletions src/types/openapi/models/ClientCertificateSignRequestDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

import type {
CertificateRequestFormat,
RequestAttributeDto,
} from './';

Expand All @@ -33,11 +34,16 @@ export interface ClientCertificateSignRequestDto {
*/
signatureAttributes?: Array<RequestAttributeDto>;
/**
* Certificate sign request (PKCS#10) encoded as Base64 string
* Certificate signing request encoded as Base64 string
* @type {string}
* @memberof ClientCertificateSignRequestDto
*/
pkcs10: string;
request: string;
/**
* @type {CertificateRequestFormat}
* @memberof ClientCertificateSignRequestDto
*/
format?: CertificateRequestFormat;
/**
* Token Profile UUID. Required if CSR is not uploaded
* @type {string}
Expand All @@ -63,3 +69,5 @@ export interface ClientCertificateSignRequestDto {
*/
customAttributes?: Array<RequestAttributeDto>;
}


4 changes: 2 additions & 2 deletions src/types/openapi/models/DataAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export interface DataAttribute {
* @memberof DataAttribute
*/
description?: string;
/**
/**
* Content of the Attribute
* @type {Array<BaseAttributeContent>}
* @memberof DataAttribute
*/
content?: Array<BaseAttributeContentDto>;
content?: Array<BaseAttributeContentDto>;
/**
* @type {AttributeType}
* @memberof DataAttribute
Expand Down

0 comments on commit 1be106e

Please sign in to comment.