mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
fixed: Adjust the api authentication sequence to preferentially process authentication to avoid incorrect authentication caused by cookies (#572)
This commit is contained in:
@@ -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({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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: '',
|
||||||
|
Reference in New Issue
Block a user