Skip to content

Commit

Permalink
fix:Resolve the issue of the getServiceAccountName function parsing a…
Browse files Browse the repository at this point in the history
…s empty during token login in kubeedge version 1.19.1

Signed-off-by: ryan-jay-qiu <[email protected]>
  • Loading branch information
ryan-jay-qiu committed Jan 10, 2025
1 parent 9a6b862 commit 5488ff9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helper/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 5488ff9

Please sign in to comment.