diff --git a/openmetadata-ui/src/main/resources/ui/src/assets/img/icon-aws-cognito.png b/openmetadata-ui/src/main/resources/ui/src/assets/img/icon-aws-cognito.png new file mode 100644 index 00000000000..65d1b7304cb Binary files /dev/null and b/openmetadata-ui/src/main/resources/ui/src/assets/img/icon-aws-cognito.png differ diff --git a/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx b/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx index 33fffe590fe..edfe2474fbb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx @@ -203,7 +203,9 @@ export const AuthProvider = ({ .then((res: AxiosResponse) => { if (res.data) { const updatedUserData = getUserDataFromOidc(res.data, user); - if (!matchUserDetails(res.data, updatedUserData, ['profile'])) { + if ( + !matchUserDetails(res.data, updatedUserData, ['profile', 'email']) + ) { getUpdatedUser(updatedUserData, res.data); } else { appState.updateUserDetails(res.data); @@ -416,7 +418,8 @@ export const AuthProvider = ({ ); } case AuthTypes.GOOGLE: - case AuthTypes.CUSTOM_OIDC: { + case AuthTypes.CUSTOM_OIDC: + case AuthTypes.AWS_COGNITO: { return authConfig ? ( { ['auth0', 'Sign in with auth0'], ['azure', 'Sign in with azure'], ['custom-oidc', 'Sign in with sso'], + ['aws-cognito', 'Sign in with aws cognito'], ['unknown-provider', 'SSO Provider unknown-provider is not supported'], ])( 'Sign in button should render correctly for %s', diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx index ff4e6f6f27d..b03cbed085d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx @@ -80,6 +80,12 @@ const SigninPage = () => { break; } + case AuthTypes.AWS_COGNITO: { + ssoBrandLogo = Icons.COGNITO_ICON; + ssoBrandName = 'AWS Cognito'; + + break; + } case AuthTypes.AZURE: { ssoBrandLogo = Icons.AZURE_ICON; ssoBrandName = 'Azure'; diff --git a/openmetadata-ui/src/main/resources/ui/src/router/AppRouter.tsx b/openmetadata-ui/src/main/resources/ui/src/router/AppRouter.tsx index f4917a44aaa..f271d6cedab 100644 --- a/openmetadata-ui/src/main/resources/ui/src/router/AppRouter.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/router/AppRouter.tsx @@ -32,13 +32,19 @@ const AppRouter = () => { getCallBackComponent, } = useAuthContext(); const callbackComponent = getCallBackComponent(); + const oidcProviders = [ + AuthTypes.GOOGLE, + AuthTypes.AWS_COGNITO, + AuthTypes.CUSTOM_OIDC, + ]; + const isOidcProvider = + authConfig?.provider && oidcProviders.includes(authConfig.provider); return loading ? ( ) : ( <> - {authConfig?.provider === AuthTypes.GOOGLE || - authConfig?.provider === AuthTypes.CUSTOM_OIDC ? ( + {isOidcProvider ? ( ) : ( <> diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/AuthProvider.util.ts b/openmetadata-ui/src/main/resources/ui/src/utils/AuthProvider.util.ts index e3a12f2fef6..0e4faf06d7f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/AuthProvider.util.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/AuthProvider.util.ts @@ -42,7 +42,7 @@ export const getRedirectUri = (callbackUrl: string) => { export const getUserManagerConfig = ( authClient: Record = {} ): Record => { - const { authority, clientId, callbackUrl } = authClient; + const { authority, clientId, callbackUrl, responseType, scope } = authClient; return { authority, @@ -50,10 +50,10 @@ export const getUserManagerConfig = ( // eslint-disable-next-line @typescript-eslint/camelcase client_id: clientId, // eslint-disable-next-line @typescript-eslint/camelcase - response_type: 'id_token', + response_type: responseType, // eslint-disable-next-line @typescript-eslint/camelcase redirect_uri: getRedirectUri(callbackUrl), - scope: 'openid email profile', + scope, userStore: new WebStorageStateStore({ store: localStorage }), }; }; @@ -87,6 +87,8 @@ export const getAuthConfig = ( callbackUrl: redirectUri, provider, providerName, + scope: 'openid email profile', + responseType: 'id_token', }; } @@ -98,6 +100,21 @@ export const getAuthConfig = ( clientId, callbackUrl: redirectUri, provider, + scope: 'openid email profile', + responseType: 'id_token', + }; + } + + break; + case AuthTypes.AWS_COGNITO: + { + config = { + authority, + clientId, + callbackUrl: redirectUri, + provider, + scope: 'openid email profile', + responseType: 'code', }; } diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/SvgUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/SvgUtils.tsx index 6a60401e360..c710f82598f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/SvgUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/SvgUtils.tsx @@ -13,6 +13,7 @@ import React, { FunctionComponent } from 'react'; import IconAuth0 from '../assets/img/icon-auth0.png'; +import IconCognito from '../assets/img/icon-aws-cognito.png'; import IconAzure from '../assets/img/icon-azure.png'; import IconGithub from '../assets/img/icon-github.png'; import IconGoogle from '../assets/img/icon-google.png'; @@ -156,6 +157,7 @@ export const Icons = { AZURE_ICON: 'azure-icon', GOOGLE_ICON: 'google-icon', OKTA_ICON: 'okta-icon', + COGNITO_ICON: 'cognito-icon', GITHUB_ICON: 'github-icon', AUTH0_ICON: 'auth0-icon', EDIT: 'icon-edit', @@ -354,6 +356,10 @@ const SVGIcons: FunctionComponent = ({ case Icons.OKTA_ICON: IconComponent = IconOkta; + break; + case Icons.COGNITO_ICON: + IconComponent = IconCognito; + break; case Icons.GITHUB_ICON: IconComponent = IconGithub; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/UserDataUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/UserDataUtils.ts index 4d5f8bae671..d112e302e8c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/UserDataUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/UserDataUtils.ts @@ -12,7 +12,7 @@ */ import { AxiosError, AxiosResponse } from 'axios'; -import { isEmpty, isEqual, isUndefined } from 'lodash'; +import { isEqual, isUndefined } from 'lodash'; import { SearchedUsersAndTeams, SearchResponse } from 'Models'; import AppState from '../AppState'; import { OidcUser } from '../authentication/auth-provider/AuthProvider.interface'; @@ -64,11 +64,14 @@ export const getUserDataFromOidc = ( const images = oidcUser.profile.picture ? getImages(oidcUser.profile.picture) : undefined; + const profileEmail = oidcUser.profile.email; + const email = profileEmail ? profileEmail : userData.email; return { ...userData, + email, displayName: oidcUser.profile.name, - profile: !isEmpty(images) ? { images } : userData.profile, + profile: images ? { images } : userData.profile, }; };