Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add option to choose between relative and absolute path for client certificates (fixes: #3108) (improves: #3109) #3822

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => {
const keyFilePathInputRef = useRef();
const pfxFilePathInputRef = useRef();

const [pathType, setPathType] = useState('absolute');

const formik = useFormik({
initialValues: {
domain: '',
Expand Down Expand Up @@ -70,13 +72,15 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => {
const getFile = (e) => {
const filePath = window?.ipcRenderer?.getFilePath(e?.files?.[0]);
if (filePath) {
let relativePath;
if (isWindowsOS()) {
relativePath = slash(path.win32.relative(root, filePath));
if (pathType === 'relative') {
const relativePath = isWindowsOS()
? slash(path.win32.relative(root, filePath))
: path.posix.relative(root, filePath);

formik.setFieldValue(e.name, relativePath);
} else {
relativePath = path.posix.relative(root, filePath);
formik.setFieldValue(e.name, filePath);
}
formik.setFieldValue(e.name, relativePath);
}
};

Expand All @@ -101,6 +105,10 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => {
}
};

const handlePathType = (e) => {
setPathType(e.target.value);
}

return (
<StyledWrapper className="w-full h-full">
<div className="text-xs mb-4 text-muted">Add client certificates to be used for specific domains.</div>
Expand Down Expand Up @@ -164,7 +172,7 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => {
/>
Cert
</label>
<label className="flex items-center ml-4 cursor-pointer" htmlFor="pfx">
<label className="flex items-center ml-10 cursor-pointer" htmlFor="pfx">
<input
id="pfx"
type="radio"
Expand All @@ -178,6 +186,37 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => {
</label>
</div>
</div>
<div className="mb-3 flex items-center">
<label id="path-type-label" className="settings-label">
Path Type
</label>
<div className="flex items-center" aria-labelledby="path-type-label">
<label className="flex items-center cursor-pointer" htmlFor="relative">
<input
id="relative"
type="radio"
name="pathType"
value="relative"
checked={pathType === 'relative'}
onChange={handlePathType}
className="mr-1"
/>
Relative
</label>
<label className="flex items-center ml-4 cursor-pointer" htmlFor="absolute">
<input
id="absolute"
type="radio"
name="pathType"
value="absolute"
checked={pathType === 'absolute'}
onChange={handlePathType}
className="mr-1"
/>
Absolute
</label>
</div>
</div>
{formik.values.type === 'cert' ? (
<>
<div className="mb-3 flex items-center">
Expand Down
Loading