mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-22 16:08:13 +00:00
parent
c50f71b478
commit
aa81ceab1a
@ -30,14 +30,12 @@ import React, {
|
|||||||
} from 'react';
|
} from 'react';
|
||||||
import { useHistory, useLocation } from 'react-router-dom';
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
import appState from '../AppState';
|
import appState from '../AppState';
|
||||||
// import GoogleAuthenticator from '../authenticators/GoogleAuthenticator';
|
|
||||||
import MsalAuthenticator from '../authenticators/MsalAuthenticator';
|
import MsalAuthenticator from '../authenticators/MsalAuthenticator';
|
||||||
import OidcAuthenticator from '../authenticators/OidcAuthenticator';
|
import OidcAuthenticator from '../authenticators/OidcAuthenticator';
|
||||||
import OktaAuthenticator from '../authenticators/OktaAuthenticator';
|
import OktaAuthenticator from '../authenticators/OktaAuthenticator';
|
||||||
import axiosClient from '../axiosAPIs';
|
import axiosClient from '../axiosAPIs';
|
||||||
import {
|
import {
|
||||||
fetchAuthenticationConfig,
|
fetchAuthenticationConfig,
|
||||||
fetchAuthorizerConfig,
|
|
||||||
getLoggedInUserPermissions,
|
getLoggedInUserPermissions,
|
||||||
} from '../axiosAPIs/miscAPI';
|
} from '../axiosAPIs/miscAPI';
|
||||||
import {
|
import {
|
||||||
@ -46,7 +44,7 @@ import {
|
|||||||
updateUser,
|
updateUser,
|
||||||
} from '../axiosAPIs/userAPI';
|
} from '../axiosAPIs/userAPI';
|
||||||
import Loader from '../components/Loader/Loader';
|
import Loader from '../components/Loader/Loader';
|
||||||
import { NOOP_FILTER, NO_AUTH } from '../constants/auth.constants';
|
import { NO_AUTH } from '../constants/auth.constants';
|
||||||
import { isAdminUpdated, oidcTokenKey, ROUTES } from '../constants/constants';
|
import { isAdminUpdated, oidcTokenKey, ROUTES } from '../constants/constants';
|
||||||
import { ClientErrors } from '../enums/axios.enum';
|
import { ClientErrors } from '../enums/axios.enum';
|
||||||
import { AuthTypes } from '../enums/signin.enum';
|
import { AuthTypes } from '../enums/signin.enum';
|
||||||
@ -250,63 +248,35 @@ export const AuthProvider = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fetchAuthConfig = (): void => {
|
const fetchAuthConfig = (): void => {
|
||||||
const promises = [fetchAuthenticationConfig(), fetchAuthorizerConfig()];
|
fetchAuthenticationConfig()
|
||||||
Promise.allSettled(promises)
|
.then((authRes: AxiosResponse) => {
|
||||||
.then(
|
const isSecureMode =
|
||||||
([
|
!isNil(authRes.data) && authRes.data.provider !== NO_AUTH;
|
||||||
authenticationConfig,
|
if (isSecureMode) {
|
||||||
authorizerConfig,
|
const { provider, authority, clientId, callbackUrl } = authRes.data;
|
||||||
]: PromiseSettledResult<AxiosResponse>[]) => {
|
const configJson = getAuthConfig({
|
||||||
let authRes = {} as AxiosResponse;
|
authority,
|
||||||
if (authenticationConfig.status === 'fulfilled') {
|
clientId,
|
||||||
authRes = authenticationConfig.value;
|
callbackUrl,
|
||||||
const authorizerRes =
|
provider,
|
||||||
authorizerConfig.status === 'fulfilled'
|
});
|
||||||
? authorizerConfig.value
|
setAuthConfig(configJson);
|
||||||
: ({} as AxiosResponse);
|
updateAuthInstance(configJson);
|
||||||
const isSecureMode =
|
if (!oidcUserToken) {
|
||||||
!isNil(authRes.data) &&
|
setLoading(false);
|
||||||
authorizerRes?.data?.containerRequestFilter &&
|
|
||||||
authRes.data.provider !== NO_AUTH &&
|
|
||||||
authorizerRes.data.containerRequestFilter !== NOOP_FILTER &&
|
|
||||||
Object.values(authRes.data).filter((item) => isNil(item))
|
|
||||||
.length === 0;
|
|
||||||
if (isSecureMode) {
|
|
||||||
const { provider, authority, clientId, callbackUrl } =
|
|
||||||
authRes.data;
|
|
||||||
const configJson = getAuthConfig({
|
|
||||||
authority,
|
|
||||||
clientId,
|
|
||||||
callbackUrl,
|
|
||||||
provider,
|
|
||||||
});
|
|
||||||
setAuthConfig(configJson);
|
|
||||||
updateAuthInstance(configJson);
|
|
||||||
if (!oidcUserToken) {
|
|
||||||
setLoading(false);
|
|
||||||
} else {
|
|
||||||
getAuthenticatedUser(configJson);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setLoading(false);
|
|
||||||
setIsAuthDisabled(true);
|
|
||||||
fetchAllUsers();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
authenticationConfig.reason as AxiosError;
|
getAuthenticatedUser(configJson);
|
||||||
showToast({
|
|
||||||
variant: 'error',
|
|
||||||
body:
|
|
||||||
(authenticationConfig.reason as AxiosError).response?.data
|
|
||||||
.message || 'Error occured while fetching auth config',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setLoading(false);
|
||||||
|
setIsAuthDisabled(true);
|
||||||
|
fetchAllUsers();
|
||||||
}
|
}
|
||||||
)
|
})
|
||||||
.catch(() => {
|
.catch((err: AxiosError) => {
|
||||||
showToast({
|
showToast({
|
||||||
variant: 'error',
|
variant: 'error',
|
||||||
body: 'Error occured while fetching auth config',
|
body: `Error occurred while fetching auth config: ${err.message}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -55,10 +55,6 @@ export const fetchAuthenticationConfig: Function =
|
|||||||
return APIClient.get('/config/auth');
|
return APIClient.get('/config/auth');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchAuthorizerConfig: Function = (): Promise<AxiosResponse> => {
|
|
||||||
return APIClient.get('/config/authorizer');
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fetchSandboxConfig = (): Promise<AxiosResponse> => {
|
export const fetchSandboxConfig = (): Promise<AxiosResponse> => {
|
||||||
return APIClient.get('/config/sandbox');
|
return APIClient.get('/config/sandbox');
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user