Skip to content

Commit 18633df

Browse files
Construct commonauth URL with tenant qualified organization path in the sub organization connection creation
1 parent 7a481c7 commit 18633df

8 files changed

Lines changed: 56 additions & 4 deletions

File tree

.changeset/large-toys-whisper.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@wso2is/console": patch
3+
"@wso2is/admin.connections.v1": patch
4+
"@wso2is/admin.core.v1": patch
5+
---
6+
7+
Construct commonauth URL with tenant qualified organization path in the sub organization connection creation

apps/console/java/org.wso2.identity.apps.console.server.feature/resources/deployment.config.json.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
"i18nResourcePath": "{{ console.i18n_resource_path }}",
8383
"loginCallbackPath": "{{ console.login_callback_path }}",
8484
"logoutCallbackPath": "{{ console.logout_callback_path }}",
85+
"organizations": {
86+
"connections": {
87+
"useTenantQualifiedOrgPatternCommonauth": {{ console.organizations.connections.use_tenant_qualified_org_pattern_commonauth | default(false) }}
88+
}
89+
},
8590
{% if console.proxy_context_path is defined %}
8691
"proxyContextPath": "{{ console.proxy_context_path }}",
8792
{% endif %}

apps/console/src/init/app-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ export const AppUtils: any = (function() {
266266
organizationName: this.getOrganizationName(),
267267
organizationPrefix: this.getOrganizationPrefix(),
268268
organizationType: this.getOrganizationType(),
269+
organizations: _config.organizations,
269270
productVersionConfig: _config.ui.productVersionConfig,
270271
proxyContextPath: this.getProxyContextPath(),
271272
regionSelectionEnabled: _config.regionSelectionEnabled,

apps/console/src/public/deployment.config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@
265265
},
266266
"loginCallbackPath": "",
267267
"logoutCallbackPath": "",
268+
"organizations": {
269+
"connections": {
270+
"useTenantQualifiedOrgPatternCommonauth": false
271+
}
272+
},
268273
"proxyContextPath": "",
269274
"routePaths": {
270275
"home": "/getting-started",

features/admin.connections.v1/components/create/enterprise-connection-create-wizard.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ import { ConfigReducerStateInterface } from "@wso2is/admin.core.v1/models/reduce
3030
import { AppState } from "@wso2is/admin.core.v1/store";
3131
import { EventPublisher } from "@wso2is/admin.core.v1/utils/event-publisher";
3232
import { commonConfig } from "@wso2is/admin.extensions.v1";
33+
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";
3334
import { IdentityAppsError } from "@wso2is/core/errors";
34-
import { AlertLevels, IdentifiableComponentInterface,
35-
HttpErrorResponseDataInterface
35+
import { AlertLevels, HttpErrorResponseDataInterface,
36+
IdentifiableComponentInterface
3637
} from "@wso2is/core/models";
3738
import { addAlert } from "@wso2is/core/store";
3839
import { URLUtils } from "@wso2is/core/utils";
@@ -163,6 +164,9 @@ export const EnterpriseConnectionCreateWizard: FC<EnterpriseConnectionCreateWiza
163164
const [ isUserInputIdpNameAlreadyTaken, setIsUserInputIdpNameAlreadyTaken ] = useState<boolean>(undefined);
164165

165166
const config: ConfigReducerStateInterface = useSelector((state: AppState) => state.config);
167+
const currentOrganizationId: string = useSelector((state: AppState) => state.organization.organization.id);
168+
169+
const { isSubOrganization } = useGetCurrentOrganizationType();
166170

167171
const dispatch: Dispatch = useDispatch();
168172
const { t } = useTranslation();
@@ -298,7 +302,14 @@ export const EnterpriseConnectionCreateWizard: FC<EnterpriseConnectionCreateWiza
298302
{ "key": "ClientSecret", "value": values?.clientSecret?.toString() },
299303
{ "key": "OAuth2AuthzEPUrl", "value": values?.authorizationEndpointUrl?.toString() },
300304
{ "key": "OAuth2TokenEPUrl", "value": values?.tokenEndpointUrl?.toString() },
301-
{ "key": "callbackUrl", "value": config?.deployment?.customServerHost + "/commonauth" }
305+
{
306+
"key": "callbackUrl",
307+
"value": isSubOrganization() &&
308+
config?.deployment?.organizations?.connections?.useTenantQualifiedOrgPatternCommonauth
309+
? `${config?.deployment?.serverOrigin}/t/${config?.deployment?.tenant}` +
310+
`/${config?.deployment?.organizationPrefix}/${currentOrganizationId}/commonauth`
311+
: `${config?.deployment?.customServerHost}/commonauth`
312+
}
302313
];
303314
// Certificates: bind the JWKS URL if exists otherwise pem
304315
identityProvider[ "certificate" ][ "jwksUri" ] = values.jwks_endpoint ?? EMPTY_STRING;

features/admin.connections.v1/components/edit/forms/authenticators/saml-authenticator-form.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Typography from "@oxygen-ui/react/Typography";
2222
import { ConfigReducerStateInterface } from "@wso2is/admin.core.v1/models/reducer-state";
2323
import { AppState } from "@wso2is/admin.core.v1/store";
2424
import { identityProviderConfig } from "@wso2is/admin.extensions.v1";
25+
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";
2526
import { isFeatureEnabled } from "@wso2is/core/helpers";
2627
import { FeatureAccessConfigInterface, TestableComponentInterface } from "@wso2is/core/models";
2728
import { DropdownChild, Field, Form, composeValidators } from "@wso2is/form";
@@ -164,6 +165,10 @@ export const SamlAuthenticatorSettingsForm: FunctionComponent<SamlSettingsFormPr
164165
);
165166

166167
const config: ConfigReducerStateInterface = useSelector((state: AppState) => state.config);
168+
const currentOrganizationId: string = useSelector((state: AppState) => state.organization.organization.id);
169+
170+
const { isSubOrganization } = useGetCurrentOrganizationType();
171+
167172
const { t } = useTranslation();
168173

169174
const [ formValues, setFormValues ] = useState<SamlPropertiesInterface>({} as SamlPropertiesInterface);
@@ -242,7 +247,11 @@ export const SamlAuthenticatorSettingsForm: FunctionComponent<SamlSettingsFormPr
242247
{ key: 25, text: "Custom Authentication Context Class", value: "Custom Authentication Context Class" }
243248
];
244249

245-
const authorizedRedirectURL: string = config?.deployment?.customServerHost + "/commonauth";
250+
const authorizedRedirectURL: string = isSubOrganization() &&
251+
config?.deployment?.organizations?.connections?.useTenantQualifiedOrgPatternCommonauth
252+
? `${config?.deployment?.serverOrigin}/t/${config?.deployment?.tenant}` +
253+
`/${config?.deployment?.organizationPrefix}/${currentOrganizationId}/commonauth`
254+
: `${config?.deployment?.customServerHost}/commonauth`;
246255

247256
/**
248257
* ISAuthnReqSigned, IsLogoutReqSigned these two fields states will be used by other

features/admin.core.v1/configs/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export class Config {
202202
idpConfigs: window[ "AppUtils" ]?.getConfig()?.idpConfigs,
203203
loginCallbackUrl: window[ "AppUtils" ]?.getConfig()?.loginCallbackURL,
204204
organizationPrefix: window["AppUtils"]?.getConfig()?.organizationPrefix,
205+
organizations: window["AppUtils"]?.getConfig()?.organizations,
205206
regionSelectionEnabled: window[ "AppUtils" ]?.getConfig()?.regionSelectionEnabled,
206207
serverHost: window[ "AppUtils" ]?.getConfig()?.serverOriginWithTenant,
207208
serverOrigin: window[ "AppUtils" ]?.getConfig()?.serverOrigin,

modules/core/src/models/config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ export interface CommonDeploymentConfigInterface<T = Record<string, unknown>, S
122122
* usage: `/${organizationPrefix}/<org_id>` - `/o/<org_id>`
123123
*/
124124
organizationPrefix: string;
125+
/**
126+
* Organization-level configurations.
127+
*/
128+
organizations?: OrganizationsConfigInterface;
125129
/**
126130
* Host of the Identity Sever.
127131
* ex: https://localhost:9443
@@ -162,6 +166,15 @@ export interface CommonDeploymentConfigInterface<T = Record<string, unknown>, S
162166
tenantPrefix: string;
163167
}
164168

169+
/**
170+
* Organizations configuration interface.
171+
*/
172+
export interface OrganizationsConfigInterface {
173+
connections?: {
174+
useTenantQualifiedOrgPatternCommonauth?: boolean;
175+
};
176+
}
177+
165178
/**
166179
* Tenant context interface.
167180
*/

0 commit comments

Comments
 (0)