Skip to content

Commit

Permalink
fix(server): fix runtime logging interface not authenticated (#1725)
Browse files Browse the repository at this point in the history
  • Loading branch information
HUAHUAI23 authored Dec 7, 2023
1 parent 0753824 commit 6e41123
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions server/src/application/pod.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export class PodController {
if (!podName) {
return ResponseUtil.error('no podName')
}
const podNames: PodNameListDto =
await this.podService.getPodNameListByAppid(appid)

if (!podNames.podNameList.includes(podName)) {
return ResponseUtil.error('podName not exist')
}

const containerNames: ContainerNameListDto =
await this.podService.getContainerNameListByPodName(appid, podName)
return ResponseUtil.ok(containerNames)
Expand Down
17 changes: 12 additions & 5 deletions server/src/log/log.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Log } from '@kubernetes/client-node'
import { GetApplicationNamespace } from 'src/utils/getter'
import { RegionService } from 'src/region/region.service'
import { ClusterService } from 'src/region/cluster/cluster.service'
import { Observable, async } from 'rxjs'
import { Observable } from 'rxjs'
import { PodService } from 'src/application/pod.service'

@ApiBearerAuth('Authorization')
Expand Down Expand Up @@ -107,10 +107,17 @@ export class LogController {
if (!containerName) {
containerName = appid
}
let podNameList: string[] = undefined
if (podName === 'all') {
podNameList = (await this.podService.getPodNameListByAppid(appid))
.podNameList

let podNameList: string[] = (
await this.podService.getPodNameListByAppid(appid)
).podNameList

if (!podNameList.includes(podName) && podName !== 'all') {
return ResponseUtil.error('podName not exist')
}

if (podName !== 'all') {
podNameList = undefined
}

const region = await this.regionService.findByAppId(appid)
Expand Down

0 comments on commit 6e41123

Please sign in to comment.