Skip to content

Commit 5fd3a57

Browse files
committed
audit fix
1 parent e28e46d commit 5fd3a57

File tree

8 files changed

+213
-221
lines changed

8 files changed

+213
-221
lines changed

frontend/src/api/domain.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ class Domain extends Curd {
1313
get_template() {
1414
return http.get('template')
1515
}
16-
17-
cert_info(path: string) {
18-
return http.get('cert_info?ssl_certificate_path=' + path)
19-
}
20-
16+
2117
add_auto_cert(domain: string) {
2218
return http.post('cert/' + domain)
2319
}

frontend/src/views/domain/DomainEdit.vue

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const ngx_config = reactive({
2424
servers: []
2525
})
2626
27+
const cert_info_map: any = reactive({})
28+
2729
const auto_cert = ref(false)
2830
const enabled = ref(false)
2931
const configText = ref('')
@@ -33,13 +35,23 @@ const saving = ref(false)
3335
3436
init()
3537
38+
function handle_response(r: any) {
39+
40+
Object.keys(cert_info_map).forEach(v => {
41+
delete cert_info_map[v]
42+
})
43+
44+
configText.value = r.config
45+
enabled.value = r.enabled
46+
auto_cert.value = r.auto_cert
47+
Object.assign(ngx_config, r.tokenized)
48+
Object.assign(cert_info_map, r.cert_info)
49+
}
50+
3651
function init() {
3752
if (name.value) {
3853
domain.get(name.value).then((r: any) => {
39-
configText.value = r.config
40-
enabled.value = r.enabled
41-
auto_cert.value = r.auto_cert
42-
Object.assign(ngx_config, r.tokenized)
54+
handle_response(r)
4355
}).catch(r => {
4456
message.error(r.message ?? $gettext('Server error'))
4557
})
@@ -74,9 +86,8 @@ const save = async () => {
7486
}
7587
7688
domain.save(name.value, {content: configText.value}).then(r => {
77-
configText.value = r.config
78-
enabled.value = r.enabled
79-
Object.assign(ngx_config, r.tokenized)
89+
handle_response(r)
90+
8091
message.success($gettext('Saved successfully'))
8192
8293
}).catch((e: any) => {
@@ -151,6 +162,7 @@ function on_change_enabled(checked: boolean) {
151162
<ngx-config-editor
152163
ref="ngx_config_editor"
153164
:ngx_config="ngx_config"
165+
:cert_info="cert_info_map"
154166
v-model:auto_cert="auto_cert"
155167
:enabled="enabled"
156168
@callback="save()"

frontend/src/views/domain/cert/Cert.vue

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,18 @@ import CertInfo from '@/views/domain/cert/CertInfo.vue'
33
import IssueCert from '@/views/domain/cert/IssueCert.vue'
44
import {computed, ref} from 'vue'
55
6-
const props = defineProps(['directivesMap', 'current_server_directives', 'enabled'])
6+
const props = defineProps(['directivesMap', 'current_server_directives', 'enabled', 'cert_info'])
77
88
const emit = defineEmits(['callback', 'update:enabled'])
99
10-
const info = ref(null)
11-
12-
interface Info {
13-
get(): void
14-
}
15-
1610
function callback() {
17-
const t: Info | null = info.value
18-
t!.get()
1911
emit('callback')
2012
}
2113
2214
const name = computed(() => {
2315
return props.directivesMap['server_name'][0].params.trim()
2416
})
2517
26-
const ssl_certificate_path = computed(() => {
27-
return props.directivesMap['ssl_certificate']?.[0].params.trim() ?? null
28-
})
29-
30-
3118
const enabled = computed({
3219
get() {
3320
return props.enabled
@@ -41,7 +28,8 @@ const enabled = computed({
4128

4229
<template>
4330
<div>
44-
<cert-info ref="info" :ssl_certificate_path="ssl_certificate_path" v-if="ssl_certificate_path"/>
31+
<cert-info ref="info" :cert="props.cert_info"/>
32+
4533
<issue-cert
4634
:current_server_directives="props.current_server_directives"
4735
:directives-map="props.directivesMap"

frontend/src/views/domain/cert/CertInfo.vue

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,13 @@ import dayjs from 'dayjs'
44
import {reactive, ref} from 'vue'
55
import domain from '@/api/domain'
66
7-
const props = defineProps(['ssl_certificate_path'])
7+
const props = defineProps(['cert'])
88
9-
const ok = ref(false)
10-
const cert = reactive({issuer_name: '', subject_name: '', not_after: '', not_before: ''})
11-
12-
get()
13-
14-
function get() {
15-
domain.cert_info(props.ssl_certificate_path).then((r: any) => {
16-
Object.assign(cert, r)
17-
ok.value = true
18-
}).catch(() => {
19-
ok.value = false
20-
})
21-
}
22-
23-
defineExpose({
24-
get
25-
})
9+
const cert = props.cert
2610
</script>
2711

2812
<template>
29-
<div class="cert-info" v-if="ok">
13+
<div class="cert-info" v-if="cert">
3014
<h2 v-translate>Certificate Status</h2>
3115
<p v-translate="{issuer: cert.issuer_name}">Intermediate Certification Authorities: %{issuer}</p>
3216
<p v-translate="{name: cert.subject_name}">Subject Name: %{name}</p>

frontend/src/views/domain/ngx_conf/NgxConfigEditor.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Cert from '@/views/domain/cert/Cert.vue'
88
99
const {$gettext} = useGettext()
1010
11-
const props = defineProps(['ngx_config', 'auto_cert', 'enabled'])
11+
const props = defineProps(['ngx_config', 'auto_cert', 'enabled', 'cert_info'])
1212
1313
const emit = defineEmits(['callback', 'update:auto_cert'])
1414
@@ -143,6 +143,7 @@ const autoCertRef = computed({
143143
<template v-if="current_support_ssl&&enabled">
144144
<cert
145145
v-if="current_support_ssl"
146+
:cert_info="props.cert_info[k]"
146147
:current_server_directives="current_server_directives"
147148
:directives-map="directivesMap"
148149
v-model:enabled="autoCertRef"

0 commit comments

Comments
 (0)