Skip to content

Commit

Permalink
Merge pull request #5964 from anjuchamantha/dcr-configs-ui
Browse files Browse the repository at this point in the history
Adding new DCR Application Settings Page
  • Loading branch information
brionmario authored Jun 24, 2024
2 parents 40bcfee + 69dcc96 commit 62d460b
Show file tree
Hide file tree
Showing 19 changed files with 17,536 additions and 12,338 deletions.
8 changes: 8 additions & 0 deletions .changeset/warm-spies-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@wso2is/admin.applications.v1": minor
"@wso2is/admin.extensions.v1": minor
"@wso2is/admin.core.v1": minor
"@wso2is/i18n": minor
---

Adding a new page with tenant-wise DCR configurations
60 changes: 60 additions & 0 deletions features/admin.applications.v1/api/applications-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react";
import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { store } from "../../admin.core.v1/store";
import { ApplicationsSettingsFormValuesInterface, DCRConfigUpdateType } from "../models/applications-settings";

/**
* Get an axios instance.
*/
const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance()
.httpRequest.bind(AsgardeoSPAClient.getInstance());

/**
* Updates the DCR Configurations.
*
* @returns A promise containing the response.
*/
export const updateDCRConfigurations = (
updateData: Array<DCRConfigUpdateType>
): Promise<ApplicationsSettingsFormValuesInterface | void> => {

const requestConfig: AxiosRequestConfig = {
data: updateData,
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.PATCH,
url: store.getState().config.endpoints.dcrConfiguration
};

return httpClient(requestConfig)
.then((response: AxiosResponse) => {
if (response.status !== 200) {
return Promise.reject(new Error("Failed to update DCR Configuration."));
}

return Promise.resolve(response.data as ApplicationsSettingsFormValuesInterface);
}).catch((error: AxiosError) => {
return Promise.reject(error);
});
};
55 changes: 55 additions & 0 deletions features/admin.applications.v1/api/use-get-dcr-configurations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { HttpMethods } from "@wso2is/core/models";
import { AxiosRequestConfig } from "axios";
import useRequest, {
RequestErrorInterface,
RequestResultInterface
} from "../../admin.core.v1/hooks/use-request";
import { store } from "../../admin.core.v1/store";
import { ApplicationsSettingsFormValuesInterface } from "../models/applications-settings";

/**
* Hook to get the dcr configurations from the API.
*
* @returns Response as a promise.
*/
export const useGetDCRConfigurations = <Data = ApplicationsSettingsFormValuesInterface, Error = RequestErrorInterface>(
shouldFetch: boolean = true
): RequestResultInterface<Data, Error> => {

const requestConfig: AxiosRequestConfig = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: `${ store.getState().config.endpoints.dcrConfiguration}`
};

const { data, error, isValidating, mutate } = useRequest<Data, Error>(shouldFetch ? requestConfig : null);

return {
data,
error: error,
isLoading: !error && !data,
isValidating,
mutate
};
};
1 change: 1 addition & 0 deletions features/admin.applications.v1/configs/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const getApplicationsResourceEndpoints = (serverHost: string): Applicatio

return {
applications: `${ serverHost }/api/server/v1/applications`,
dcrConfiguration: `${ serverHost }/api/server/v1/configs/dcr`,
myAccountConfigMgt: `${ serverHostWithoutOPath }/api/identity/config-mgt/v1.0/resource/myaccount`,
requestPathAuthenticators: `${ serverHost }/api/server/v1/configs/authenticators?type=REQUEST_PATH`
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class ApplicationManagementConstants {
.set("APPLICATION_NATIVE_AUTHENTICATION", "applications.native.authentication")
.set("APPLICATION_MYACCOUNT_SAAS_SETTINGS", "applications.myaccount.saasMyaccountSettings")
.set("APPLICATION_ADD_MANAGEMENT_APPLICATIONS", "applications.add.managementApplications")
.set("APPLICATIONS_SETTINGS", "applications.settings")

/**
* Key for the `Edit Application` tag in the docs structure object.
Expand Down
95 changes: 95 additions & 0 deletions features/admin.applications.v1/models/applications-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { IdentifiableComponentInterface } from "@wso2is/core/models";

/**
* Form values interface.
*/
export interface ApplicationsSettingsFormValuesInterface {
/**
* Is the mandateSSA enabled.
*/
mandateSSA?: boolean;
/**
* Is the requireAuthentication enabled.
*/
authenticationRequired?: boolean;
/**
* JWKS Endpoint Url.
*/
ssaJwks?: string;
/**
* Is fapi complience enforced for the dcr apps.
*/
enableFapiEnforcement?: boolean
}

/**
* DCR Config update type.
*/
export interface DCRConfigUpdateType {
/**
* Operation type.
*/
operation: string;
/**
* Path type.
*/
path: string;
/**
* Value type.
*/
value: string | boolean;
}

/**
* Proptypes for the applications settings form component.
*/
export interface ApplicationsSettingsPropsInterface extends IdentifiableComponentInterface {
/**
* Is the SSA(Software Statement Assertion) mandated.
*/
mandateSSA?: boolean;
/**
* Is the requireAuthentication enabled.
*/
authenticationRequired?: boolean;
/**
* JWKS Endpoint Url to validate SSA(Software Statement Assertion).
*/
ssaJwks?: string;
/**
* DCR Endpoint Url.
*/
dcrEndpoint?: string;
/**
* Is fapi compliance enforced for the DCR apps.
*/
enableFapiEnforcement?: boolean
}

/**
* Proptypes for the applications settings form error messages.
*/
export interface ApplicationsSettingsFormErrorValidationsInterface {
/**
* Error message for the JWKS URL.
*/
ssaJwks?: string;
}
6 changes: 5 additions & 1 deletion features/admin.applications.v1/models/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand All @@ -25,6 +25,10 @@ export interface ApplicationsResourceEndpointsInterface {
applications: string;
myAccountConfigMgt: string;
requestPathAuthenticators: string;
/**
* Below route is to fetch the dcr configuration from server configurations api.
*/
dcrConfiguration: string;
}

export interface UpdateClaimConfiguration {
Expand Down
Loading

0 comments on commit 62d460b

Please sign in to comment.