Skip to content

Commit

Permalink
fixed: Adjust the api authentication sequence to preferentially proce…
Browse files Browse the repository at this point in the history
…ss authentication to avoid incorrect authentication caused by cookies (#572)
  • Loading branch information
angular-moon authored Dec 7, 2023
1 parent f298b90 commit 54d52d8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/service/support/permission/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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: '',
Expand Down

0 comments on commit 54d52d8

Please sign in to comment.