Skip to content

Commit

Permalink
Merge pull request #6679 from JayaShakthi97/post-unification-1
Browse files Browse the repository at this point in the history
Cleanup identity-providers feature (Pt.10)
  • Loading branch information
JayaShakthi97 authored Jul 31, 2024
2 parents 13f84bb + 40fee44 commit 34a7477
Show file tree
Hide file tree
Showing 42 changed files with 548 additions and 526 deletions.
10 changes: 10 additions & 0 deletions .changeset/silent-ears-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@wso2is/admin.authentication-flow-builder.v1": patch
"@wso2is/admin.identity-providers.v1": patch
"@wso2is/admin.login-flow.ai.v1": patch
"@wso2is/admin.applications.v1": patch
"@wso2is/admin.connections.v1": patch
"@wso2is/admin.extensions.v1": patch
---

Cleanup authenticator constants in admin.identity-providers feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ import {
import {
FederatedAuthenticatorConstants
} from "@wso2is/admin.connections.v1/constants/federated-authenticator-constants";
import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants";
import { ConnectionsManagementUtils }
from "@wso2is/admin.connections.v1/utils/connection-utils";
import { AppConstants, EventPublisher, FeatureConfigInterface, history } from "@wso2is/admin.core.v1";
import useUIConfig from "@wso2is/admin.core.v1/hooks/use-ui-configs";
import {
IdentityProviderManagementConstants
} from "@wso2is/admin.identity-providers.v1/constants/identity-provider-management-constants";
import MicrosoftIDPTemplate
from
"@wso2is/admin.identity-providers.v1/data/identity-provider-templates/templates/microsoft/microsoft.json";
Expand Down Expand Up @@ -252,19 +250,19 @@ export const SignOnMethodsCore: FunctionComponent<SignOnMethodsCorePropsInterfac

response[1].filter((authenticator: GenericAuthenticatorInterface) => {
if (authenticator.defaultAuthenticator.authenticatorId
=== IdentityProviderManagementConstants.GOOGLE_OIDC_AUTHENTICATOR_ID) {
=== FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.GOOGLE_OIDC_AUTHENTICATOR_ID) {

google.push(authenticator);
} else if (authenticator.defaultAuthenticator.authenticatorId
=== IdentityProviderManagementConstants.GITHUB_AUTHENTICATOR_ID) {
=== FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.GITHUB_AUTHENTICATOR_ID) {

gitHub.push(authenticator);
} else if (authenticator.defaultAuthenticator.authenticatorId
=== IdentityProviderManagementConstants.FACEBOOK_AUTHENTICATOR_ID) {
=== FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.FACEBOOK_AUTHENTICATOR_ID) {

facebook.push(authenticator);
} else if (authenticator.defaultAuthenticator.authenticatorId
=== IdentityProviderManagementConstants.MICROSOFT_AUTHENTICATOR_ID &&
=== FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.MICROSOFT_AUTHENTICATOR_ID &&
authenticator.description === MicrosoftIDPTemplate.description) {

microsoft.push(authenticator);
Expand Down Expand Up @@ -326,7 +324,7 @@ export const SignOnMethodsCore: FunctionComponent<SignOnMethodsCorePropsInterfac
}

const isBasicStep: boolean = authenticationSequence.steps[0].options[0].authenticator
=== IdentityProviderManagementConstants.BASIC_AUTHENTICATOR;
=== LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BASIC_AUTHENTICATOR_NAME;
const isBasicScript: boolean = !authenticationSequence.script
||AdaptiveScriptUtils.isDefaultScript(authenticationSequence.script, authenticationSequence.steps?.length);

Expand Down Expand Up @@ -605,19 +603,19 @@ export const SignOnMethodsCore: FunctionComponent<SignOnMethodsCorePropsInterfac

if (loginType === LoginFlowTypes.GOOGLE_LOGIN) {
modifiedSequenceTemplate = cloneDeep(GoogleLoginSequenceTemplate);
authenticatorType = IdentityProviderManagementConstants.GOOGLE_OIDC_AUTHENTICATOR_NAME;
authenticatorType = FederatedAuthenticatorConstants.AUTHENTICATOR_NAMES.GOOGLE_OIDC_AUTHENTICATOR_NAME;
} else if (loginType === LoginFlowTypes.GITHUB_LOGIN) {
modifiedSequenceTemplate = cloneDeep(GitHubLoginSequenceTemplate);
authenticatorType = IdentityProviderManagementConstants.GITHUB_AUTHENTICATOR_NAME;
authenticatorType = FederatedAuthenticatorConstants.AUTHENTICATOR_NAMES.GITHUB_AUTHENTICATOR_NAME;
} else if (loginType === LoginFlowTypes.FACEBOOK_LOGIN) {
modifiedSequenceTemplate = cloneDeep(FacebookLoginSequenceTemplate);
authenticatorType = IdentityProviderManagementConstants.FACEBOOK_AUTHENTICATOR_NAME;
authenticatorType = FederatedAuthenticatorConstants.AUTHENTICATOR_NAMES.FACEBOOK_AUTHENTICATOR_NAME;
} else if (loginType === LoginFlowTypes.MICROSOFT_LOGIN) {
modifiedSequenceTemplate = cloneDeep(MicrosoftLoginSequenceTemplate);
authenticatorType = IdentityProviderManagementConstants.MICROSOFT_AUTHENTICATOR_NAME;
authenticatorType = FederatedAuthenticatorConstants.AUTHENTICATOR_NAMES.MICROSOFT_AUTHENTICATOR_NAME;
} else if (loginType === LoginFlowTypes.APPLE_LOGIN) {
modifiedSequenceTemplate = cloneDeep(AppleLoginSequenceTemplate);
authenticatorType = IdentityProviderManagementConstants.APPLE_AUTHENTICATOR_NAME;
authenticatorType = FederatedAuthenticatorConstants.AUTHENTICATOR_NAMES.APPLE_AUTHENTICATOR_NAME;
}
modifiedSequenceTemplate.steps[0].options.forEach((option: AuthenticatorInterface) => {
if (option.authenticator === authenticatorType) {
Expand All @@ -640,19 +638,24 @@ export const SignOnMethodsCore: FunctionComponent<SignOnMethodsCorePropsInterfac

if (socialDisclaimerModalType === LoginFlowTypes.GOOGLE_LOGIN) {
idpTemplateTypeToTrigger = CommonAuthenticatorManagementConstants.CONNECTION_TEMPLATE_IDS.GOOGLE;
authenticatorName = IdentityProviderManagementConstants.GOOGLE_OIDC_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.GOOGLE_OIDC_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.GITHUB_LOGIN) {
idpTemplateTypeToTrigger = CommonAuthenticatorManagementConstants.CONNECTION_TEMPLATE_IDS.GITHUB;
authenticatorName = IdentityProviderManagementConstants.GITHUB_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.GITHUB_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.FACEBOOK_LOGIN) {
idpTemplateTypeToTrigger = CommonAuthenticatorManagementConstants.CONNECTION_TEMPLATE_IDS.FACEBOOK;
authenticatorName = IdentityProviderManagementConstants.FACEBOOK_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.FACEBOOK_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.MICROSOFT_LOGIN) {
idpTemplateTypeToTrigger = CommonAuthenticatorManagementConstants.CONNECTION_TEMPLATE_IDS.MICROSOFT;
authenticatorName = IdentityProviderManagementConstants.MICROSOFT_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.MICROSOFT_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.APPLE_LOGIN) {
idpTemplateTypeToTrigger = CommonAuthenticatorManagementConstants.CONNECTION_TEMPLATE_IDS.APPLE;
authenticatorName = IdentityProviderManagementConstants.APPLE_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.APPLE_AUTHENTICATOR_DISPLAY_NAME;
} else {
return null;
}
Expand Down Expand Up @@ -732,19 +735,24 @@ export const SignOnMethodsCore: FunctionComponent<SignOnMethodsCorePropsInterfac

if (socialDisclaimerModalType === LoginFlowTypes.GOOGLE_LOGIN) {
authenticators = [ ...googleAuthenticators ];
authenticatorName = IdentityProviderManagementConstants.GOOGLE_OIDC_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.GOOGLE_OIDC_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.GITHUB_LOGIN) {
authenticators = [ ...gitHubAuthenticators ];
authenticatorName = IdentityProviderManagementConstants.GITHUB_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.GITHUB_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.FACEBOOK_LOGIN) {
authenticators = [ ...facebookAuthenticators ];
authenticatorName = IdentityProviderManagementConstants.FACEBOOK_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.FACEBOOK_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.MICROSOFT_LOGIN) {
authenticators = [ ...microsoftAuthenticators ];
authenticatorName = IdentityProviderManagementConstants.MICROSOFT_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.MICROSOFT_AUTHENTICATOR_DISPLAY_NAME;
} else if (socialDisclaimerModalType === LoginFlowTypes.APPLE_LOGIN) {
authenticators = [ ...appleAuthenticators ];
authenticatorName = IdentityProviderManagementConstants.APPLE_AUTHENTICATOR_DISPLAY_NAME;
authenticatorName = FederatedAuthenticatorConstants
.AUTHENTICATOR_DISPLAY_NAMES.APPLE_AUTHENTICATOR_DISPLAY_NAME;
} else {
return null;
}
Expand Down Expand Up @@ -811,8 +819,8 @@ export const SignOnMethodsCore: FunctionComponent<SignOnMethodsCorePropsInterfac
{
authenticators
.filter((authenticator: GenericAuthenticatorInterface) => {
return authenticator.name !== IdentityProviderManagementConstants
.BACKUP_CODE_AUTHENTICATOR;
return authenticator.name !== LocalAuthenticatorConstants.AUTHENTICATOR_NAMES
.BACKUP_CODE_AUTHENTICATOR_NAME;
})
.map((authenticator: GenericAuthenticatorInterface, index: number) => (
<LabeledCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import useAuthenticationFlow from "@wso2is/admin.authentication-flow-builder.v1/hooks/use-authentication-flow";
import { AuthenticatorManagementConstants } from "@wso2is/admin.connections.v1";
import { getMultiFactorAuthenticatorDetails } from "@wso2is/admin.connections.v1/api/authenticators";
import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants";
import {
AppConstants,
AppState,
Expand All @@ -27,9 +28,6 @@ import {
history
} from "@wso2is/admin.core.v1";
import useGlobalVariables from "@wso2is/admin.core.v1/hooks/use-global-variables";
import {
IdentityProviderManagementConstants
} from "@wso2is/admin.identity-providers.v1/constants/identity-provider-management-constants";
import { GenericAuthenticatorInterface } from "@wso2is/admin.identity-providers.v1/models/identity-provider";
import { OrganizationType } from "@wso2is/admin.organizations.v1/constants";
import {
Expand Down Expand Up @@ -608,15 +606,17 @@ export const SignInMethodCustomization: FunctionComponent<SignInMethodCustomizat
(step: AuthenticationStepInterface) =>
!!step?.options.find(
(authenticator: AuthenticatorInterface) =>
authenticator?.authenticator === IdentityProviderManagementConstants.FIDO_AUTHENTICATOR
authenticator?.authenticator === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES
.FIDO_AUTHENTICATOR_NAME
)
);

if (isPasskeyIncludedInAnyStep) {
if (isPasskeyProgressiveEnrollmentEnabled) {
const isPasskeyIncludedAsAFirstFatorOption: boolean = !!authenticationSequence?.steps[0]?.options.find(
(authenticator: AuthenticatorInterface) =>
authenticator?.authenticator === IdentityProviderManagementConstants.FIDO_AUTHENTICATOR
authenticator?.authenticator === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES
.FIDO_AUTHENTICATOR_NAME
);

if (isPasskeyIncludedAsAFirstFatorOption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
*/
import useAuthenticationFlow from "@wso2is/admin.authentication-flow-builder.v1/hooks/use-authentication-flow";
import { ConnectionManagementConstants } from "@wso2is/admin.connections.v1/constants/connection-constants";
import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants";
import { EventPublisher, FeatureConfigInterface } from "@wso2is/admin.core.v1";
import useDeploymentConfig from "@wso2is/admin.core.v1/hooks/use-deployment-configs";
import {
IdentityProviderManagementConstants
} from "@wso2is/admin.identity-providers.v1/constants/identity-provider-management-constants";
import { IdentifiableComponentInterface, SBACInterface } from "@wso2is/core/models";
import { Heading, InfoCard, useMediaContext } from "@wso2is/react-components";
import React, { FunctionComponent, ReactElement } from "react";
Expand Down Expand Up @@ -233,7 +231,7 @@ export const SignInMethodLanding: FunctionComponent<SignInMethodLandingPropsInte
</Heading>
{ !hiddenOptions?.includes(LoginFlowTypes.FIDO_LOGIN) &&
!hiddenAuthenticators?.includes(
IdentityProviderManagementConstants.FIDO_AUTHENTICATOR
LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.FIDO_AUTHENTICATOR_NAME
) && (
<InfoCard
fluid
Expand Down Expand Up @@ -262,7 +260,7 @@ export const SignInMethodLanding: FunctionComponent<SignInMethodLandingPropsInte
) }
{ !hiddenOptions?.includes(LoginFlowTypes.MAGIC_LINK) &&
!hiddenAuthenticators?.includes(
IdentityProviderManagementConstants.MAGIC_LINK_AUTHENTICATOR
LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.MAGIC_LINK_AUTHENTICATOR_NAME
) && (
<InfoCard
fluid
Expand Down Expand Up @@ -292,7 +290,7 @@ export const SignInMethodLanding: FunctionComponent<SignInMethodLandingPropsInte
) }
{ !hiddenOptions?.includes(LoginFlowTypes.EMAIL_OTP) &&
!hiddenAuthenticators?.includes(
IdentityProviderManagementConstants.EMAIL_OTP_AUTHENTICATOR_ID
LocalAuthenticatorConstants.AUTHENTICATOR_IDS.EMAIL_OTP_AUTHENTICATOR_ID
) && (
<InfoCard
fluid
Expand Down Expand Up @@ -322,7 +320,7 @@ export const SignInMethodLanding: FunctionComponent<SignInMethodLandingPropsInte
) }
{ !hiddenOptions?.includes(LoginFlowTypes.SMS_OTP) &&
!hiddenAuthenticators?.includes(
IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR_ID
LocalAuthenticatorConstants.AUTHENTICATOR_IDS.SMS_OTP_AUTHENTICATOR_ID
) && (
<InfoCard
fluid
Expand Down
Loading

0 comments on commit 34a7477

Please sign in to comment.