fixed: Adjust the api authentication sequence to preferentially process authentication to avoid incorrect authentication caused by cookies (#572)

This commit is contained in:
angular-moon
2023-12-07 18:19:18 +08:00
committed by GitHub
parent f298b90b69
commit 54d52d8d25

View File

@@ -115,6 +115,18 @@ export async function parseHeaderCert({
{}) as ReqHeaderAuthType;
const { uid, teamId, tmbId, appId, openApiKey, authType } = await (async () => {
if (authApiKey && authorization) {
// apikey from authorization
const authResponse = await parseAuthorization(authorization);
return {
uid: authResponse.uid,
teamId: authResponse.teamId,
tmbId: authResponse.tmbId,
appId: authResponse.appId,
openApiKey: authResponse.apikey,
authType: AuthUserTypeEnum.apikey
};
}
if (authToken && (cookie || token)) {
// user token(from fastgpt web)
const res = await authCookieToken(cookie, token);
@@ -152,18 +164,6 @@ export async function parseHeaderCert({
};
}
if (authApiKey && authorization) {
// apikey from authorization
const authResponse = await parseAuthorization(authorization);
return {
uid: authResponse.uid,
teamId: authResponse.teamId,
tmbId: authResponse.tmbId,
appId: authResponse.appId,
openApiKey: authResponse.apikey,
authType: AuthUserTypeEnum.apikey
};
}
return {
uid: '',
teamId: '',