From 5488ff9f36fc47a9036aea83ab3dd6667d9b41d5 Mon Sep 17 00:00:00 2001 From: ryan-jay-qiu <839169472@qq.com> Date: Fri, 10 Jan 2025 16:25:35 +0800 Subject: [PATCH] fix:Resolve the issue of the getServiceAccountName function parsing as empty during token login in kubeedge version 1.19.1 Signed-off-by: ryan-jay-qiu <839169472@qq.com> --- src/helper/token.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helper/token.ts b/src/helper/token.ts index 7249a2b..056b277 100644 --- a/src/helper/token.ts +++ b/src/helper/token.ts @@ -9,7 +9,7 @@ export const getServiceAccountName = async (token: string) => { const decodedPayload = JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/'))); // Extract the 'sub' field - const sub = decodedPayload['kubernetes.io/serviceaccount/service-account.name']; - + const sub = decodedPayload['kubernetes.io/serviceaccount/service-account.name'] || + decodedPayload["kubernetes.io"].serviceaccount.name; return sub || null; };