[FIX]: tokenType까지 검사하여 OAuth Flow인지 확인
This commit is contained in:
parent
b1c10b0739
commit
1bc442b1d3
1 changed files with 47 additions and 26 deletions
|
|
@ -132,7 +132,7 @@ export class AccessTokenLeakController {
|
||||||
* @param text - 검사할 텍스트
|
* @param text - 검사할 텍스트
|
||||||
* @returns 토큰 값이 있으면 해당 값, 없으면 null
|
* @returns 토큰 값이 있으면 해당 값, 없으면 null
|
||||||
*/
|
*/
|
||||||
private extractTokenFromText(text: string): string | null {
|
private extractTokenFromText(text: string): string | null {
|
||||||
// 토큰 관련 키워드 리스트
|
// 토큰 관련 키워드 리스트
|
||||||
const tokenKeys = [
|
const tokenKeys = [
|
||||||
'access_token',
|
'access_token',
|
||||||
|
|
@ -151,7 +151,26 @@ private extractTokenFromText(text: string): string | null {
|
||||||
'session_token'
|
'session_token'
|
||||||
];
|
];
|
||||||
|
|
||||||
// 정규표현식 패턴 리스트 생성
|
const tokenTypeKeys = [
|
||||||
|
'token_type',
|
||||||
|
'tokenType'
|
||||||
|
];
|
||||||
|
|
||||||
|
// 정규표현식 토큰 타입 유무 패턴 리스트 생성
|
||||||
|
const tokenTypeRegexes: RegExp[] = [];
|
||||||
|
for (const key of tokenTypeKeys) {
|
||||||
|
// JSON 형식: "token_type": "Bearer"
|
||||||
|
tokenTypeRegexes.push(new RegExp(`"${key}"\\s*:\\s*"bearer"`, 'i'));
|
||||||
|
// 일반 key=value 형식: token_type=Bearer
|
||||||
|
tokenTypeRegexes.push(new RegExp(`${key}[=:]\\s*bearer`, 'i'));
|
||||||
|
// 공백 있는 형식: token_type : Bearer
|
||||||
|
tokenTypeRegexes.push(new RegExp(`${key}\\s*:\\s*bearer`, 'i'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// token_type=bearer 형태 중 하나라도 포함되는지 확인
|
||||||
|
const hasTokenTypeBearer = tokenTypeRegexes.some(rx => rx.test(text));
|
||||||
|
|
||||||
|
// 정규표현식 토큰 유무 패턴 리스트 생성
|
||||||
const tokenPatterns: RegExp[] = [];
|
const tokenPatterns: RegExp[] = [];
|
||||||
|
|
||||||
for (const key of tokenKeys) {
|
for (const key of tokenKeys) {
|
||||||
|
|
@ -169,9 +188,11 @@ private extractTokenFromText(text: string): string | null {
|
||||||
for (const pattern of tokenPatterns) {
|
for (const pattern of tokenPatterns) {
|
||||||
const match = pattern.exec(text);
|
const match = pattern.exec(text);
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
|
if(hasTokenTypeBearer){
|
||||||
return match[1];
|
return match[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue