Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Achintha Isuru committed Oct 29, 2023
2 parents 978cc65 + 008e356 commit 76e64ee
Show file tree
Hide file tree
Showing 29 changed files with 245 additions and 146 deletions.
12 changes: 12 additions & 0 deletions apps/console/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @wso2is/console

## 2.5.7

### Patch Changes

- [#4427](https://github.com/wso2/identity-apps/pull/4427) [`728741fb00`](https://github.com/wso2/identity-apps/commit/728741fb00bab58d7736c1e9365631944fd1aa8b) Thanks [@brionmario](https://github.com/brionmario)! - Fix RBAC issues

## 2.5.6

### Patch Changes

- [#4426](https://github.com/wso2/identity-apps/pull/4426) [`580864ec22`](https://github.com/wso2/identity-apps/commit/580864ec220f997cbacf41956f051aa0f1ed4e9c) Thanks [@DonOmalVindula](https://github.com/DonOmalVindula)! - Hide org switch breadcrumb in Super org

## 2.5.5

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.identity.apps</groupId>
<artifactId>identity-apps-console</artifactId>
<version>2.5.3-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"appWhiteLogoPath": "{{ console.ui.app_white_logo_path }}",
"emailTemplates": {
"defaultLogoUrl": "{{ console.ui.email_templates.default_logo_url }}",
"defaultWhiteLogoUrl": "{{ console.ui.email_templates.default_white_logo_url }}",
"defaultWhiteLogoUrl": "{{ console.ui.email_templates.default_white_logo_url }}"
},
"appFaviconPath": "{{ console.ui.app_favicon_path }}",
"googleOneTapEnabledTenants": [
Expand Down
2 changes: 1 addition & 1 deletion apps/console/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<groupId>org.wso2.identity.apps</groupId>
<artifactId>identity-apps-console</artifactId>
<packaging>pom</packaging>
<version>2.5.3-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<name>WSO2 Identity Server Console - Parent</name>
<description>WSO2 Identity Server Console Parent</description>

Expand Down
2 changes: 1 addition & 1 deletion apps/console/java/webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.identity.apps</groupId>
<artifactId>identity-apps-console</artifactId>
<version>2.5.3-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion apps/console/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@wso2is/console",
"version": "2.5.5",
"version": "2.5.7",
"description": "WSO2 Identity Server Console",
"author": "WSO2",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/console/src/extensions/configs/identity-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const identityProviderConfig: IdentityProviderConfig = {
AuthenticatorLabels.PASSKEY
],
filterFidoTags: (tags: string[]): string[] => {
return tags.filter((tag: string) =>
return tags.filter((tag: string) =>
tag === AuthenticatorLabels.PASSWORDLESS || tag === AuthenticatorLabels.PASSKEY);
},
generalDetailsForm: {
Expand All @@ -265,7 +265,7 @@ export const identityProviderConfig: IdentityProviderConfig = {
},
jitProvisioningSettings: {
enableAssociateLocalUserField: {
show: !!window[ "AppUtils" ].getConfig().organizationName
show: !!window[ "AppUtils" ]?.getConfig()?.organizationName
},
enableJitProvisioningField: {
show: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const SecretSelectionDropdown = (props: SecretSelectionDropdownPropsInterface):
>
<CircularProgress size={ 20 } />
</ListItem>
) : secretsList.length === 0 ? (
) : secretsList?.length === 0 ? (
<ListItem
className="create-new-secret-dropdown-empty-placeholder"
data-componentid={ `${ componentId }-list-empty-placeholder` }
Expand All @@ -172,7 +172,7 @@ const SecretSelectionDropdown = (props: SecretSelectionDropdownPropsInterface):
</ListItemText>
</ListItem>
) : (
secretsList.map((secret: SecretModel, index: number) => (
secretsList?.map((secret: SecretModel, index: number) => (
<>
<ListItem
key={ secret.secretId }
Expand All @@ -198,7 +198,7 @@ const SecretSelectionDropdown = (props: SecretSelectionDropdownPropsInterface):
<TrashIcon size={ 14 } />
</IconButton>
</ListItem>
{ index !== secretsList.length - 1 && <Divider /> }
{ index !== secretsList?.length - 1 && <Divider /> }
</>
))
) }
Expand Down
67 changes: 27 additions & 40 deletions apps/console/src/features/authentication/hooks/use-sign-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { ThunkDispatch } from "redux-thunk";
import useAuthorization from "../../authorization/hooks/use-authorization";
import { Config } from "../../core/configs/app";
import { AppConstants, CommonConstants } from "../../core/constants";
import { MultitenantConstants } from "../../core/constants/multitenant-constants";
import { DeploymentConfigInterface } from "../../core/models/config";
import { AppState } from "../../core/store";
import {
Expand All @@ -56,6 +55,7 @@ import {
} from "../../core/store/actions/organization";
import { OrganizationType } from "../../organizations/constants";
import useOrganizationSwitch from "../../organizations/hooks/use-organization-switch";
import useOrganizations from "../../organizations/hooks/use-organizations";
import { getProfileInformation } from "../store/actions";
import { AuthenticateUtils } from "../utils/authenticate-utils";

Expand All @@ -70,11 +70,9 @@ const LOGOUT_URL: string = "sign_out_url";
export type UseSignInInterface = {
onSignIn: (
response: BasicUserInfo,
updateOrgPaths: boolean,
onTenantResolve: (tenantDomain: string) => void,
onSignInSuccessRedirect: (idToken: DecodedIDTokenPayload) => void,
onAppReady: () => void,
_isFirstLevelOrg?: boolean,
) => Promise<void>;
};

Expand All @@ -96,13 +94,13 @@ const useSignIn = (): UseSignInInterface => {

const { legacyAuthzRuntime } = useAuthorization();

const { transformTenantDomain } = useOrganizations();

const onSignIn = async (
response: BasicUserInfo,
updateOrgPaths: boolean,
onTenantResolve: (tenantDomain: string) => void,
onSignInSuccessRedirect: (idToken: DecodedIDTokenPayload) => void,
onAppReady: () => void,
_isFirstLevelOrg?: boolean
onAppReady: () => void
): Promise<void> => {
let logoutUrl: string;
let logoutRedirectUrl: string;
Expand All @@ -119,12 +117,9 @@ const useSignIn = (): UseSignInInterface => {
const orgIdIdToken: string = idToken.org_id;
const orgName: string = idToken.org_name;
const userOrganizationId: string = idToken.user_org;
const isFirstLevelOrg: boolean = !idToken.user_org || idToken.user_org === idToken.org_id;

let tenantDomain: string = orgName;

if (tenantDomain === MultitenantConstants.SUPER_TENANT_DISPLAY_NAME) {
tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
}
let tenantDomain: string = transformTenantDomain(orgName);

if (legacyAuthzRuntime) {
tenantDomain = CommonAuthenticateUtils.deriveTenantDomainFromSubject(
Expand All @@ -136,38 +131,26 @@ const useSignIn = (): UseSignInInterface => {

let orgType: OrganizationType;

if (window["AppUtils"].getConfig().organizationName) {
orgType = OrganizationType.SUBORGANIZATION;
} else if (tenantDomain === AppConstants.getSuperTenant()) {
// Update the organization name with the newly resolved org.
if (!isFirstLevelOrg) {
window["AppUtils"].updateOrganizationName(orgIdIdToken);
} else {
// Update the app base name with the newly resolved tenant.
window[ "AppUtils" ].updateTenantQualifiedBaseName(tenantDomain);
}

if (isFirstLevelOrg && tenantDomain === AppConstants.getSuperTenant()) {
orgType = OrganizationType.SUPER_ORGANIZATION;
} else if (orgIdIdToken) {
} else if (isFirstLevelOrg) {
orgType = OrganizationType.FIRST_LEVEL_ORGANIZATION;
} else {
orgType = OrganizationType.TENANT;
orgType = OrganizationType.SUBORGANIZATION;
}

// TODO: Remove this once the hasRequiredScopes() function is moved as a hook.
window["AppUtils"].updateOrganizationType(orgType);

dispatch(setOrganizationType(orgType));
dispatch(setUserOrganizationId(userOrganizationId));

let isFirstLevelOrg: boolean = !window["AppUtils"].getConfig().organizationName && !!orgIdIdToken;

// TODO: Redux store async issue here. Fix this properly.
if (_isFirstLevelOrg === false) {
isFirstLevelOrg = false;
}

dispatch(setIsFirstLevelOrganization(isFirstLevelOrg));

// Update the organization name with the newly resolved org.
if (updateOrgPaths) {
window["AppUtils"].updateOrganizationName(orgIdIdToken);
} else {
// Update the app base name with the newly resolved tenant.
window[ "AppUtils" ].updateTenantQualifiedBaseName(tenantDomain);
}

if (window["AppUtils"].getConfig().organizationName || isFirstLevelOrg) {
// We are actually getting the orgId here rather than orgName
Expand Down Expand Up @@ -332,12 +315,16 @@ const useSignIn = (): UseSignInInterface => {

dispatch(
setSignIn<AuthenticatedUserInfo & TenantListInterface>(
Object.assign(CommonAuthenticateUtils.getSignInState(response, response.orgName), {
associatedTenants: isPrivilegedUser ? tenantDomain : idToken?.associated_tenants,
defaultTenant: isPrivilegedUser ? tenantDomain : idToken?.default_tenant,
fullName: fullName,
isPrivilegedUser: isPrivilegedUser
})
Object.assign(
CommonAuthenticateUtils.getSignInState(
response,
transformTenantDomain(response.orgName)
), {
associatedTenants: isPrivilegedUser ? tenantDomain : idToken?.associated_tenants,
defaultTenant: isPrivilegedUser ? tenantDomain : idToken?.default_tenant,
fullName: fullName,
isPrivilegedUser: isPrivilegedUser
})
)
);

Expand Down
66 changes: 9 additions & 57 deletions apps/console/src/features/branding/api/branding-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { I18nConstants } from "../../core/constants";
import { store } from "../../core/store";
import { OrganizationType } from "../../organizations/constants/organization-constants";
import { BrandingPreferencesConstants } from "../constants";
import {
BrandingPreferenceAPIResponseInterface,
Expand All @@ -36,61 +37,6 @@ const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance()
.httpRequest.bind(AsgardeoSPAClient.getInstance())
.bind(AsgardeoSPAClient.getInstance());

/**
* Get the branding preference via Branding Preferences API.
*
* @param name - Resource Name.
* @param type - Resource Type.
* @param locale - Resource Locale.
* @returns Branding Preference.
* @throws IdentityAppsApiException.
*/
export const getBrandingPreference = (
name: string,
type: BrandingPreferenceTypes = BrandingPreferenceTypes.ORG,
locale: string = I18nConstants.DEFAULT_FALLBACK_LANGUAGE
): Promise<BrandingPreferenceAPIResponseInterface> => {

const requestConfig: AxiosRequestConfig = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.GET,
params: {
locale,
name,
type
},
url: store.getState().config.endpoints.brandingPreference
};

return httpClient(requestConfig)
.then((response: AxiosResponse) => {
if (response.status !== 200) {
throw new IdentityAppsApiException(
BrandingPreferencesConstants.ErrorMessages.BRANDING_PREFERENCE_FETCH_INVALID_STATUS_CODE_ERROR
.getErrorMessage(),
null,
response.status,
response.request,
response,
response.config);
}

return Promise.resolve(response.data);
}).catch((error: AxiosError) => {
throw new IdentityAppsApiException(
error.response?.data?.message ?? BrandingPreferencesConstants
.ErrorMessages.BRANDING_PREFERENCE_FETCH_ERROR.getErrorMessage(),
error.stack,
error.response?.data?.code,
error.request,
error.response,
error.config);
});
};

/**
* Update the branding preference via Branding Preferences API.
*
Expand All @@ -109,11 +55,14 @@ export const updateBrandingPreference = (
type: BrandingPreferenceTypes = BrandingPreferenceTypes.ORG,
locale: string = I18nConstants.DEFAULT_FALLBACK_LANGUAGE
): Promise<BrandingPreferenceAPIResponseInterface> => {
const tenantDomain: string = store.getState().organization.organizationType === OrganizationType.SUBORGANIZATION
? store.getState()?.organization?.organization?.id
: name;

const requestConfig: AxiosRequestConfig = {
data: {
locale,
name,
name: tenantDomain,
preference,
type
},
Expand Down Expand Up @@ -164,6 +113,9 @@ export const deleteBrandingPreference = (
type: BrandingPreferenceTypes = BrandingPreferenceTypes.ORG,
locale: string = I18nConstants.DEFAULT_FALLBACK_LANGUAGE
): Promise<null | IdentityAppsApiException> => {
const tenantDomain: string = store.getState().organization.organizationType === OrganizationType.SUBORGANIZATION
? store.getState()?.organization?.organization?.id
: name;

const requestConfig: AxiosRequestConfig = {
headers: {
Expand All @@ -173,7 +125,7 @@ export const deleteBrandingPreference = (
method: HttpMethods.DELETE,
params: {
locale,
name,
name: tenantDomain,
type
},
url: store.getState().config.endpoints.brandingPreference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { I18nConstants } from "../../core/constants/i18n-constants";
import { store } from "../../core/store";
import { OrganizationType } from "../../organizations/constants/organization-constants";
import { CustomTextPreferenceConstants } from "../constants/custom-text-preference-constants";
import { BrandingPreferenceTypes } from "../models/branding-preferences";
import { CustomTextPreferenceAPIResponseInterface } from "../models/custom-text-preference";
Expand All @@ -48,6 +49,10 @@ const deleteCustomTextPreference = (
locale: string = I18nConstants.DEFAULT_FALLBACK_LANGUAGE,
type: BrandingPreferenceTypes = BrandingPreferenceTypes.ORG
): Promise<CustomTextPreferenceAPIResponseInterface> => {
const tenantDomain: string = store.getState().organization.organizationType === OrganizationType.SUBORGANIZATION
? store.getState()?.organization?.organization?.id
: name;

const requestConfig: AxiosRequestConfig = {
headers: {
"Accept": "application/json",
Expand All @@ -56,7 +61,7 @@ const deleteCustomTextPreference = (
method: HttpMethods.DELETE,
params: {
locale,
name,
name: tenantDomain,
screen,
type
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { I18nConstants } from "../../core/constants/i18n-constants";
import { store } from "../../core/store";
import { OrganizationType } from "../../organizations/constants/organization-constants";
import { CustomTextPreferenceConstants } from "../constants/custom-text-preference-constants";
import { BrandingPreferenceTypes } from "../models/branding-preferences";
import {
Expand Down Expand Up @@ -55,10 +56,14 @@ const updateCustomTextPreference = (
locale: string = I18nConstants.DEFAULT_FALLBACK_LANGUAGE,
type: BrandingPreferenceTypes = BrandingPreferenceTypes.ORG
): Promise<CustomTextPreferenceAPIResponseInterface> => {
const tenantDomain: string = store.getState().organization.organizationType === OrganizationType.SUBORGANIZATION
? store.getState()?.organization?.organization?.id
: name;

const requestConfig: AxiosRequestConfig = {
data: {
locale,
name,
name: tenantDomain,
preference,
screen,
type
Expand Down
Loading

0 comments on commit 76e64ee

Please sign in to comment.