Commit 54d52d8d by angular-moon Committed by GitHub

fixed: Adjust the api authentication sequence to preferentially process…

fixed: Adjust the api authentication sequence to preferentially process authentication to avoid incorrect authentication caused by cookies (#572)
parent f298b90b
...@@ -115,6 +115,18 @@ export async function parseHeaderCert({ ...@@ -115,6 +115,18 @@ export async function parseHeaderCert({
{}) as ReqHeaderAuthType; {}) as ReqHeaderAuthType;
const { uid, teamId, tmbId, appId, openApiKey, authType } = await (async () => { 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)) { if (authToken && (cookie || token)) {
// user token(from fastgpt web) // user token(from fastgpt web)
const res = await authCookieToken(cookie, token); const res = await authCookieToken(cookie, token);
...@@ -152,18 +164,6 @@ export async function parseHeaderCert({ ...@@ -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 { return {
uid: '', uid: '',
teamId: '', teamId: '',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment