Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new DCR Application Settings Page #5964

Merged
merged 23 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8b9fcde
Add DCR Configurations page
anjuchamantha Apr 9, 2024
61f9506
Add copy button to DCR Endpoint field
anjuchamantha Apr 15, 2024
35badae
Add isSubmitting loading to the button
anjuchamantha Apr 15, 2024
c2b53e7
Merge branch 'master' into dcr-configs-ui
anjuchamantha Apr 16, 2024
4f34cfd
Fix issues after merging master
anjuchamantha Apr 16, 2024
d54ec35
Refactoring DCR configurations page
anjuchamantha Apr 16, 2024
b7f0d85
Merge branch 'master' into dcr-configs-ui
anjuchamantha Apr 16, 2024
0bbb577
Use featureConfig other than AccessControlConstants
anjuchamantha Apr 16, 2024
1198724
Fix linter issues in DCR config page
anjuchamantha Apr 17, 2024
44c148e
Refactoring code in DCR config page
anjuchamantha Apr 17, 2024
3f0af06
[DCR] Change Success Alert description
anjuchamantha May 14, 2024
36dbd29
Merge branch 'master' into dcr-configs-ui
anjuchamantha May 14, 2024
d67f6c8
Merge branch 'master' into dcr-configs-ui
anjuchamantha May 15, 2024
0411474
Merge branch 'master' into dcr-configs-ui
anjuchamantha May 17, 2024
447b6d2
[DCR] Bug fix in data-componenetid values
anjuchamantha May 22, 2024
ec5d657
Merge branch 'master' into dcr-configs-ui
anjuchamantha May 30, 2024
3a2f666
[DCR] Refactoring
anjuchamantha May 30, 2024
27f07fe
Merge branch 'master' into dcr-configs-ui
anjuchamantha Jun 11, 2024
81bd4d2
Add changeset 🦋
anjuchamantha Jun 11, 2024
b339d3a
Add changeset 🦋
anjuchamantha Jun 11, 2024
6451ff5
Add ability to enable feature via config
anjuchamantha Jun 13, 2024
bd88e53
Add ability to enable applications settings button
anjuchamantha Jun 13, 2024
69dcc96
Add ability to disable using disabledFeatures array
anjuchamantha Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions features/admin.applications.v1/api/applications-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* 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.
*
anjuchamantha marked this conversation as resolved.
Show resolved Hide resolved
*/
const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance()
.httpRequest.bind(AsgardeoSPAClient.getInstance())
.bind(AsgardeoSPAClient.getInstance());
anjuchamantha marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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
};
};
3 changes: 2 additions & 1 deletion features/admin.applications.v1/configs/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const getApplicationsResourceEndpoints = (serverHost: string): Applicatio
return {
applications: `${ serverHost }/api/server/v1/applications`,
myAccountConfigMgt: `${ serverHostWithoutOPath }/api/identity/config-mgt/v1.0/resource/myaccount`,
requestPathAuthenticators: `${ serverHost }/api/server/v1/configs/authenticators?type=REQUEST_PATH`
requestPathAuthenticators: `${ serverHost }/api/server/v1/configs/authenticators?type=REQUEST_PATH`,
dcrConfiguration: `${ serverHost }/api/server/v1/configs/dcr`,
};
};
58 changes: 58 additions & 0 deletions features/admin.applications.v1/models/applications-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
*
* 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.
*/


anjuchamantha marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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;
}
4 changes: 4 additions & 0 deletions features/admin.applications.v1/models/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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