-
Notifications
You must be signed in to change notification settings - Fork 4
feat(ovpntunnel): show all cert expirations #690
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,7 @@ | |
| import { NeModal } from '@nethesis/vue-components' | ||
| import { useI18n } from 'vue-i18n' | ||
| import type { ServerTunnel, ClientTunnel } from './TunnelManager.vue' | ||
| import { watch, ref, computed } from 'vue' | ||
| import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' | ||
| import { getCertificateStatus } from './TunnelTable.vue' | ||
| import { watch, ref } from 'vue' | ||
|
|
||
| const { t, locale } = useI18n() | ||
|
|
||
|
|
@@ -32,15 +30,6 @@ const emit = defineEmits(['close']) | |
| function isClientTunnel(item: ServerTunnel | ClientTunnel): item is ClientTunnel { | ||
| return 'remote_host' in item | ||
| } | ||
|
|
||
| const certificateStatus = computed(() => { | ||
| if (!_itemToShow.value?.cert_expiry_ts) return { show: false } | ||
| return getCertificateStatus( | ||
| _itemToShow.value.cert_expiry_ts, | ||
| isClientTunnel(_itemToShow.value), | ||
| true | ||
| ) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
|
|
@@ -224,33 +213,31 @@ const certificateStatus = computed(() => { | |
| </p> | ||
| </template> | ||
|
|
||
| <!-- cert_expiry_ts --> | ||
| <p class="text-sm font-semibold"> | ||
| {{ | ||
| isClientTunnel(_itemToShow!) | ||
| ? t('standalone.openvpn_tunnel.client_cert_expiry') | ||
| : t('standalone.openvpn_tunnel.cert_expiry') | ||
| }} | ||
| </p> | ||
| <div class="flex flex-col gap-2"> | ||
| <!-- certificates --> | ||
| <template v-if="!isClientTunnel(_itemToShow!) && _itemToShow.certificates.server"> | ||
| <p class="text-sm font-semibold"> | ||
| {{ t('standalone.openvpn_tunnel.server_cert_expiration') }} | ||
| </p> | ||
| <p class="text-sm text-gray-600 dark:text-gray-400"> | ||
| {{ new Date(_itemToShow.certificates.server * 1000).toLocaleString(locale) }} | ||
gsanchietti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </p> | ||
| </template> | ||
| <template v-if="_itemToShow.certificates.client"> | ||
| <p class="text-sm font-semibold"> | ||
| {{ t('standalone.openvpn_tunnel.client_cert_expiration') }} | ||
| </p> | ||
| <p class="text-sm text-gray-600 dark:text-gray-400"> | ||
| {{ | ||
| _itemToShow.cert_expiry_ts | ||
| ? new Date(_itemToShow.cert_expiry_ts * 1000).toLocaleString(locale) | ||
| : '' | ||
| }} | ||
| {{ new Date(_itemToShow.certificates.client * 1000).toLocaleString(locale) }} | ||
gsanchietti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </p> | ||
| <span v-if="certificateStatus.show" class="flex items-center gap-2"> | ||
| <FontAwesomeIcon | ||
| :icon="certificateStatus.icon" | ||
| :class="['h-4 w-4', certificateStatus.colorClass]" | ||
| aria-hidden="true" | ||
| /> | ||
| <p class="text-sm text-gray-600 dark:text-gray-400"> | ||
| {{ t(certificateStatus.messageKey!, certificateStatus.messageParams!) }} | ||
| </p> | ||
| </span> | ||
| </div> | ||
|
Comment on lines
-243
to
-253
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, here we are removing the icon and the detail message if needed. |
||
| </template> | ||
| <template v-if="_itemToShow.certificates.CA"> | ||
| <p class="text-sm font-semibold"> | ||
| {{ t('standalone.openvpn_tunnel.ca_cert_expiration') }} | ||
| </p> | ||
| <p class="text-sm text-gray-600 dark:text-gray-400"> | ||
| {{ new Date(_itemToShow.certificates.CA * 1000).toLocaleString(locale) }} | ||
gsanchietti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </p> | ||
| </template> | ||
| </div> | ||
| </NeModal> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,19 @@ export function isCertificatesExpired(expiryTimestamp: number): boolean { | |
| } | ||
|
|
||
| export function getCertificateStatus( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Within this function, we must decide whether to compute expiration information for the CA certificate as well. |
||
| expiryTimestamp: number, | ||
| certificates: { [key: string]: number }, | ||
| isClientTunnel: boolean = false, | ||
| tunnelDetailModal: boolean = false | ||
| ): CertificateStatusResult { | ||
| if (isCertificatesExpired(expiryTimestamp)) { | ||
| // Determine which certificate to check (client for client tunnels, server for server tunnels) | ||
| const certToCheck = isClientTunnel ? certificates.client : certificates.server | ||
|
|
||
| // If the certificate is not available, return no status to show | ||
| if (!certToCheck) { | ||
| return { show: false } | ||
| } | ||
|
|
||
| if (isCertificatesExpired(certToCheck)) { | ||
| return { | ||
| show: true, | ||
| icon: faCircleExclamation, | ||
|
|
@@ -48,7 +56,7 @@ export function getCertificateStatus( | |
| } | ||
| } | ||
|
|
||
| if (shouldShowCertExpiryBadge(expiryTimestamp)) { | ||
| if (shouldShowCertExpiryBadge(certToCheck)) { | ||
| return { | ||
| show: true, | ||
| icon: faTriangleExclamation, | ||
|
|
@@ -61,7 +69,7 @@ export function getCertificateStatus( | |
| ? 'standalone.openvpn_tunnel.client_cert_expiring_message' | ||
| : 'standalone.openvpn_tunnel.cert_expiring_message', | ||
| messageParams: { | ||
| days: getDaysUntilExpiry(expiryTimestamp) | ||
| days: getDaysUntilExpiry(certToCheck) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -220,17 +228,17 @@ function checkIsClientTunnel(item: ServerTunnel | ClientTunnel): item is ClientT | |
| <p :class="[...getCellClasses(item)]">{{ item.ns_name }}</p> | ||
| <NeTooltip | ||
| v-if=" | ||
| item.cert_expiry_ts && | ||
| getCertificateStatus(item.cert_expiry_ts, checkIsClientTunnel(item)).show | ||
| item.certificates && | ||
| getCertificateStatus(item.certificates, checkIsClientTunnel(item)).show | ||
| " | ||
| interactive | ||
| > | ||
| <template #trigger> | ||
| <FontAwesomeIcon | ||
| :icon="getCertificateStatus(item.cert_expiry_ts, checkIsClientTunnel(item)).icon" | ||
| :icon="getCertificateStatus(item.certificates, checkIsClientTunnel(item)).icon" | ||
| :class="[ | ||
| 'h-4 w-4', | ||
| getCertificateStatus(item.cert_expiry_ts, checkIsClientTunnel(item)).colorClass | ||
| getCertificateStatus(item.certificates, checkIsClientTunnel(item)).colorClass | ||
| ]" | ||
| aria-hidden="true" | ||
| /> | ||
|
|
@@ -239,8 +247,7 @@ function checkIsClientTunnel(item: ServerTunnel | ClientTunnel): item is ClientT | |
| <p class="text-center"> | ||
| {{ | ||
| t( | ||
| getCertificateStatus(item.cert_expiry_ts, checkIsClientTunnel(item)) | ||
| .messageKey! | ||
| getCertificateStatus(item.certificates, checkIsClientTunnel(item)).messageKey! | ||
| ) | ||
| }} | ||
| </p> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this assignment will make the icon notifying the certificate expiration no longer visible inside the tunnel details modal. Is it correct?