From 0b3584c0edb6421e66d9ed01bd562d00cac63866 Mon Sep 17 00:00:00 2001 From: Camille Moussu Date: Thu, 2 May 2024 10:52:25 +0400 Subject: [PATCH] [+] the oidc app view is now interactive --- src/App.tsx | 10 +- src/app/store.ts | 2 - .../applicationsComponents/OIDCApp.tsx | 248 +++++--- .../applicationsComponents/OptionOidc.tsx | 571 +++++++++++++++--- src/features/config/configSlice.ts | 191 ++++++ 5 files changed, 853 insertions(+), 169 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 86e5c14..d6b71d4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,7 +11,7 @@ import { Configuration } from "./pages/Configuration"; function App() { useTranslation(); const location = useAppSelector((state) => state.router.location); - const test = location?.hash.replace("#", "").split("/"); + const infos = location?.hash.replace("#", "").split("/"); return ( @@ -23,11 +23,11 @@ function App() { element={ = {}; + + const table = document.getElementById(tableID); + const rows = table?.getElementsByTagName("tr"); + if (rows) { + for (let i = 1; i < rows.length; i++) { + const cells = rows[i].getElementsByTagName("td"); + const name = cells[0].querySelector("input")?.value; + const varName = cells[1].querySelector("input")?.value; + const type = cells[2].querySelector("select")?.value; + const array = cells[3].querySelector("select")?.value; + + attrList[name ? name : ""] = `${varName};${type};${array}`; + } + } + + return attrList; +} function ExportedAttribute(appName: string, vars: Record) { + let i = 0; + const dispatch = useAppDispatch(); return ( {Object.keys(vars).map((key) => { + i++; const [name, type, table] = vars[key].split(";"); return ( - + console.log("abab")} + onChange={() => + dispatch( + updateOidcRPMetaDataExportedVars({ + appName, + data: updateExpAttr("exportedVars"), + }) + ) + } type="text" value={key} /> @@ -21,7 +61,14 @@ function ExportedAttribute(appName: string, vars: Record) { console.log("abab")} + onChange={() => + dispatch( + updateOidcRPMetaDataExportedVars({ + appName, + data: updateExpAttr("exportedVars"), + }) + ) + } type="text" value={name} /> @@ -29,7 +76,14 @@ function ExportedAttribute(appName: string, vars: Record) { console.log(el.target.value)} + onChange={() => + dispatch( + updateOidcRPMetaDataExportedVars({ + appName, + data: updateExpAttr("exportedVars"), + }) + ) + } > @@ -48,50 +109,10 @@ function ExportedAttribute(appName: string, vars: Record) { - - - ); - })} - - ); -} - -export function tableVars(appName: string, vars: Record) { - return ( - - {Object.keys(vars).map((key) => { - return ( - - - console.log("abab")} - type="text" - value={key} - /> - - - console.log("abab")} - type="text" - value={vars[key]} - /> - - - - @@ -105,7 +126,7 @@ export function tableVars(appName: string, vars: Record) { export function OIDCApp({ name }: { name: string }) { const data = useAppSelector((state) => state.config.data.config); - + const dispatch = useAppDispatch(); return (
{name} @@ -130,7 +151,13 @@ export function OIDCApp({ name }: { name: string }) { : 0 )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsPublic", + value: 1, + }) + ); }} /> {t("on")} @@ -148,7 +175,15 @@ export function OIDCApp({ name }: { name: string }) { : 0 ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsPublic", + value: 0, + }) + ); + }} /> {t("off")} @@ -165,7 +200,15 @@ export function OIDCApp({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsClientID )} - onChange={(el) => console.log(el.target.value)} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsClientID", + value: e.target.value, + }) + ); + }} /> @@ -179,7 +222,15 @@ export function OIDCApp({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsClientSecret )} - onChange={(el) => console.log(el.target.value)} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsClientSecret", + value: e.target.value, + }) + ); + }} /> @@ -193,8 +244,14 @@ export function OIDCApp({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsRedirectUris )} - onChange={() => { - console.log("aka"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsRedirectUris", + value: e.target.value, + }) + ); }} /> @@ -209,8 +266,14 @@ export function OIDCApp({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsAuthMethod )} - onChange={() => { - console.log("aka"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAuthMethod", + value: e.target.value, + }) + ); }} /> @@ -223,9 +286,18 @@ export function OIDCApp({ name }: { name: string }) { value={String( data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsDisplay + ? data.oidcRPMetaDataOptions[name] + .oidcRPMetaDataOptionsDisplay + : "" )} - onChange={() => { - console.log("aka"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsDisplay", + value: e.target.value, + }) + ); }} /> @@ -238,8 +310,14 @@ export function OIDCApp({ name }: { name: string }) { value={String( data.oidcRPMetaDataOptions[name].oidcRPMetaDataOptionsIcon )} - onChange={() => { - console.log("aka"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsIcon", + value: e.target.value, + }) + ); }} /> @@ -249,39 +327,61 @@ export function OIDCApp({ name }: { name: string }) {
{t("oidcRPMetaDataExportedVars")} - - - - - + + + + + + {data.oidcRPMetaDataExportedVars ? ExportedAttribute(name, data.oidcRPMetaDataExportedVars[name]) : ""}
{t("claimName")}{t("variableName")}{t("type")}{t("array")}
{t("claimName")}{t("variableName")}{t("type")}{t("array")}
-
{t("oidcRPMetaDataMacros")} - - +
- - + + + + {data.oidcRPMetaDataMacros - ? tableVars(name, data.oidcRPMetaDataMacros[name]) + ? TableVars( + name, + data.oidcRPMetaDataMacros[name], + "oidcRPMetaDataMacros", + delOIDCRPMetaDataMacros, + updateOIDCRPMetaDataMacros + ) : ""}
{t("keys")}{t("values")}
{t("keys")}{t("values")}
-
diff --git a/src/components/applicationsComponents/OptionOidc.tsx b/src/components/applicationsComponents/OptionOidc.tsx index bc06cfb..5dc14ba 100644 --- a/src/components/applicationsComponents/OptionOidc.tsx +++ b/src/components/applicationsComponents/OptionOidc.tsx @@ -1,53 +1,25 @@ import { t } from "i18next"; import { useState } from "react"; import attributes from "../../static/attributes.json"; -import { useAppSelector } from "../../app/hooks"; +import { useAppDispatch, useAppSelector } from "../../app/hooks"; import { handleChangeFile } from "../../utils/readFiles"; import { URLLoader } from "../managerComponents/URLLoader"; - -function tableVars(appName: string, vars: Record) { - return ( - - {Object.keys(vars).map((key) => { - return ( - - - console.log("abab")} - type="text" - value={key} - /> - - - console.log("abab")} - type="text" - value={vars[key]} - /> - - - - - - - ); - })} - - ); -} +import { + delOidcRPMetaDataOptionsExtraClaims, + delOidcRPMetaDataScopeRules, + newOidcRPMetaDataOptionsExtraClaims, + newOidcRPMetaDataScopeRules, + updateOidcMetaDataOptions, + updateOidcRPMetaDataOptionsExtraClaims, + updateOidcRPMetaDataOptionsJwks, + updateOidcRPMetaDataScopeRules, +} from "../../features/config/configSlice"; +import { TableVars } from "./TableVars"; export function OptionOidc({ name }: { name: string }) { const [optionSelect, setOptionSelected] = useState("advanced"); const data = useAppSelector((state) => state.config.data.config); + const dispatch = useAppDispatch(); return ( <>
@@ -86,7 +58,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsBypassConsent )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsBypassConsent", + value: 1, + }) + ); }} /> {t("on")} @@ -102,7 +80,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsBypassConsent ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsBypassConsent", + value: 0, + }) + ); + }} /> {t("off")} @@ -123,7 +109,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsIDTokenForceClaims )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsIDTokenForceClaims", + value: 1, + }) + ); }} /> {t("on")} @@ -139,7 +131,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsIDTokenForceClaims ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsIDTokenForceClaims", + value: 0, + }) + ); + }} /> {t("off")} @@ -160,7 +160,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAccessTokenJWT )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAccessTokenJWT", + value: 1, + }) + ); }} /> {t("on")} @@ -176,7 +182,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAccessTokenJWT ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAccessTokenJWT", + value: 0, + }) + ); + }} /> {t("off")} @@ -197,7 +211,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAccessTokenClaims )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAccessTokenClaims", + value: 1, + }) + ); }} /> {t("on")} @@ -213,7 +233,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAccessTokenClaims ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAccessTokenClaims", + value: 0, + }) + ); + }} /> {t("off")} @@ -234,7 +262,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsRefreshToken )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsRefreshToken", + value: 1, + }) + ); }} /> {t("on")} @@ -250,7 +284,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsRefreshToken ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsRefreshToken", + value: 0, + }) + ); + }} /> {t("off")} @@ -270,8 +312,14 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsUserIDAttr : "" )} - onChange={(el) => { - console.log("akak"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsUserIDAttr", + value: e.target.value, + }) + ); }} /> @@ -289,8 +337,14 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAdditionalAudiences : "" )} - onChange={(el) => { - console.log("akak"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAdditionalAudiences", + value: e.target.value, + }) + ); }} /> @@ -304,33 +358,71 @@ export function OptionOidc({ name }: { name: string }) { {t("oidcRPMetaDataOptionsExtraClaims")} - +
- - + + + + + - {tableVars( + {TableVars( name, data.oidcRPMetaDataOptionsExtraClaims ? data.oidcRPMetaDataOptionsExtraClaims[name] - : {} + : {}, + "oidcRPMetaDataOptionsExtraClaims", + delOidcRPMetaDataOptionsExtraClaims, + updateOidcRPMetaDataOptionsExtraClaims )}
{t("keys")}{t("values")}
{t("keys")}{t("values")}
+
{t("oidcRPMetaDataScopeRules")} - +
- - + + + + + - {tableVars( + {TableVars( name, data.oidcRPMetaDataScopeRules ? data.oidcRPMetaDataScopeRules[name] - : {} + : {}, + "oidcRPMetaDataScopeRules", + delOidcRPMetaDataScopeRules, + updateOidcRPMetaDataScopeRules )}
{t("keys")}{t("values")}
{t("keys")}{t("values")}
+
)} @@ -345,6 +437,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsIDTokenSignAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsIDTokenSignAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsIDTokenSignAlg.select.map( (el) => { @@ -362,6 +463,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsAccessTokenSignAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAccessTokenSignAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsAccessTokenSignAlg.select.map( (el) => { @@ -379,6 +489,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsUserInfoSignAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsUserInfoSignAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsUserInfoSignAlg.select.map( (el) => { @@ -402,7 +521,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsRequirePKCE )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsRequirePKCE", + value: 1, + }) + ); }} /> {t("on")} @@ -418,7 +543,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsRequirePKCE ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsRequirePKCE", + value: 0, + }) + ); + }} /> {t("off")} @@ -439,7 +572,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAllowOffline )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAllowOffline", + value: 1, + }) + ); }} /> {t("on")} @@ -455,7 +594,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAllowOffline ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAllowOffline", + value: 0, + }) + ); + }} /> {t("off")} @@ -476,7 +623,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAllowPasswordGrant )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAllowPasswordGrant", + value: 1, + }) + ); }} /> {t("on")} @@ -492,7 +645,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAllowPasswordGrant ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAllowPasswordGrant", + value: 0, + }) + ); + }} /> {t("off")} @@ -513,7 +674,14 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAllowClientCredentialsGrant )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: + "oidcRPMetaDataOptionsAllowClientCredentialsGrant", + value: 1, + }) + ); }} /> {t("on")} @@ -529,7 +697,16 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAllowClientCredentialsGrant ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: + "oidcRPMetaDataOptionsAllowClientCredentialsGrant", + value: 0, + }) + ); + }} /> {t("off")} @@ -549,8 +726,14 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsRequestUris : "" )} - onChange={(el) => { - console.log("akak"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsRequestUris", + value: e.target.value, + }) + ); }} /> @@ -568,8 +751,14 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAuthnLevel : "" )} - onChange={(el) => { - console.log("akak"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAuthnLevel", + value: e.target.value, + }) + ); }} /> @@ -586,8 +775,14 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsRule : "" )} - onChange={(el) => { - console.log("akak"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsRule", + value: e.target.value, + }) + ); }} /> @@ -600,6 +795,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsAccessTokenEncKeyMgtAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAccessTokenEncKeyMgtAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsAccessTokenEncKeyMgtAlg.select.map( (el) => { @@ -617,6 +821,16 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsAccessTokenEncContentEncAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: + "oidcRPMetaDataOptionsAccessTokenEncContentEncAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsAccessTokenEncContentEncAlg.select.map( (el) => { @@ -634,6 +848,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsIdTokenEncKeyMgtAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsIdTokenEncKeyMgtAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsIdTokenEncKeyMgtAlg.select.map( (el) => { @@ -651,6 +874,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsIdTokenEncContentEncAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsIdTokenEncContentEncAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsIdTokenEncContentEncAlg.select.map( (el) => { @@ -668,6 +900,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsUserInfoEncKeyMgtAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsUserInfoEncKeyMgtAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsUserInfoEncKeyMgtAlg.select.map( (el) => { @@ -685,6 +926,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsUserInfoEncContentEncAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsUserInfoEncContentEncAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsUserInfoEncContentEncAlg.select.map( (el) => { @@ -702,6 +952,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsLogoutEncKeyMgtAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsLogoutEncKeyMgtAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsLogoutEncKeyMgtAlg.select.map( (el) => { @@ -719,6 +978,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsLogoutEncContentEncAlg )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsLogoutEncContentEncAlg", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsLogoutEncContentEncAlg.select.map( (el) => { @@ -747,18 +1015,23 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsJwksUri : "" )} - onChange={(el) => { - console.log("akak"); + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsJwksUri", + value: e.target.value, + }) + ); }} /> - {t("samlSPMetaDataXML")} + {t("oidcRPMetaDataOptionsJwks")}
@@ -778,11 +1060,21 @@ export function OptionOidc({ name }: { name: string }) { onChange={(e) => { handleChangeFile(e).then((fileContent) => { console.log("File content:", fileContent); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsJwks", + value: fileContent, + }) + ); }); }} />
- + @@ -802,6 +1094,16 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAuthorizationCodeExpiration : "" )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: + "oidcRPMetaDataOptionsAuthorizationCodeExpiration", + value: e.target.value, + }) + ); + }} /> @@ -817,6 +1119,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsIDTokenExpiration : "" )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsIDTokenExpiration", + value: e.target.value, + }) + ); + }} /> @@ -832,6 +1143,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsAccessTokenExpiration : "" )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsAccessTokenExpiration", + value: e.target.value, + }) + ); + }} /> @@ -847,6 +1167,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsOfflineSessionExpiration : "" )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsOfflineSessionExpiration", + value: e.target.value, + }) + ); + }} /> @@ -870,7 +1199,13 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsLogoutBypassConfirm )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsLogoutBypassConfirm", + value: 1, + }) + ); }} /> {t("on")} @@ -886,7 +1221,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsLogoutBypassConfirm ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsLogoutBypassConfirm", + value: 0, + }) + ); + }} /> {t("off")} @@ -907,7 +1250,14 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsLogoutSessionRequired )} onChange={() => { - console.log("aka"); + dispatch( + updateOidcMetaDataOptions({ + name, + option: + "oidcRPMetaDataOptionsLogoutSessionRequired", + value: 1, + }) + ); }} /> {t("on")} @@ -923,7 +1273,16 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsLogoutSessionRequired ) } - onChange={() => console.log("akak")} + onChange={() => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: + "oidcRPMetaDataOptionsLogoutSessionRequired", + value: 0, + }) + ); + }} /> {t("off")} @@ -938,6 +1297,15 @@ export function OptionOidc({ name }: { name: string }) { data.oidcRPMetaDataOptions[name] .oidcRPMetaDataOptionsLogoutType )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsLogoutType", + value: e.target.value, + }) + ); + }} > {attributes.oidcRPMetaDataOptionsLogoutType.select.map( (el) => { @@ -959,6 +1327,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsLogoutUrl : "" )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsLogoutUrl", + value: e.target.value, + }) + ); + }} /> @@ -974,6 +1351,15 @@ export function OptionOidc({ name }: { name: string }) { .oidcRPMetaDataOptionsPostLogoutRedirectUris : "" )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsPostLogoutRedirectUris", + value: e.target.value, + }) + ); + }} /> @@ -987,6 +1373,15 @@ export function OptionOidc({ name }: { name: string }) { ? data.oidcRPMetaDataOptions[name].oidcRPMetaDataOptionsComment : "" )} + onChange={(e) => { + dispatch( + updateOidcMetaDataOptions({ + name, + option: "oidcRPMetaDataOptionsComment", + value: e.target.value, + }) + ); + }} /> )} diff --git a/src/features/config/configSlice.ts b/src/features/config/configSlice.ts index 474e3c6..531abeb 100644 --- a/src/features/config/configSlice.ts +++ b/src/features/config/configSlice.ts @@ -246,6 +246,21 @@ const configSlice = createSlice({ state.data.config.samlSPMetaDataXML[action.payload.name] = { samlSPMetaDataXML: "", }; + if (!state.data.config.samlSPMetaDataExportedAttributes) { + state.data.config.samlSPMetaDataExportedAttributes = {}; + } + state.data.config.samlSPMetaDataExportedAttributes[ + action.payload.name + ] = attributes.samlSPMetaDataExportedAttributes.default; + if (!state.data.config.samlSPMetaDataMacros) { + state.data.config.samlSPMetaDataMacros = + attributes.samlSPMetaDataMacros.default; + } + state.data.config.samlSPMetaDataMacros[action.payload.name] = {}; + if (!state.data.config.samlSPMetaDataOptions) { + state.data.config.samlSPMetaDataOptions = {}; + } + state.data.config.samlSPMetaDataOptions[action.payload.name] = {}; break; case "oidc": state.data.config.oidcRPMetaDataOptions[action.payload.name] = { @@ -280,11 +295,33 @@ const configSlice = createSlice({ oidcRPMetaDataOptionsRequirePKCE: attributes.oidcRPMetaDataOptionsRequirePKCE.default, }; + if (!state.data.config.oidcRPMetaDataExportedVars) { + state.data.config.oidcRPMetaDataExportedVars = {}; + } + state.data.config.oidcRPMetaDataExportedVars[action.payload.name] = + attributes.oidcRPMetaDataExportedVars.default; + if (!state.data.config.oidcRPMetaDataMacros) { + state.data.config.oidcRPMetaDataMacros = {}; + } + state.data.config.oidcRPMetaDataMacros[action.payload.name] = + attributes.oidcRPMetaDataMacros.default; break; case "cas": state.data.config.casAppMetaDataOptions[action.payload.name] = { casAppMetaDataOptionsService: "", + casAppMetaDataOptionsLogout: + attributes.casAppMetaDataOptionsLogout.default, }; + if (!state.data.config.casAppMetaDataMacros) { + state.data.config.casAppMetaDataMacros = {}; + } + state.data.config.casAppMetaDataMacros[action.payload.name] = + attributes.casAppMetaDataMacros.default; + if (!state.data.config.casAppMetaDataExportedVars) { + state.data.config.casAppMetaDataExportedVars = {}; + } + state.data.config.casAppMetaDataExportedVars[action.payload.name] = + attributes.casAppMetaDataExportedVars.default; break; default: break; @@ -467,6 +504,146 @@ const configSlice = createSlice({ action.payload.option ] = action.payload.value; }, + newOIDCRPMetaDataMacros(state, action: PayloadAction) { + if (!state.data.config.oidcRPMetaDataMacros) { + state.data.config.oidcRPMetaDataMacros = {}; + } + state.data.config.oidcRPMetaDataMacros[action.payload] = { + ...state.data.config.oidcRPMetaDataMacros[action.payload], + new: "", + }; + }, + updateOIDCRPMetaDataMacros( + state, + action: PayloadAction<{ name: string; data: Record }> + ) { + if (!state.data.config.oidcRPMetaDataMacros) { + state.data.config.oidcRPMetaDataMacros = {}; + } + state.data.config.oidcRPMetaDataMacros[action.payload.name] = + action.payload.data; + }, + delOIDCRPMetaDataMacros( + state, + action: PayloadAction<{ name: string; key: string }> + ) { + if (state.data.config.oidcRPMetaDataMacros) { + delete state.data.config.oidcRPMetaDataMacros[action.payload.name][ + action.payload.key + ]; + } + }, + updateOidcRPMetaDataExportedVars( + state, + action: PayloadAction<{ appName: string; data: Record }> + ) { + if (!state.data.config.oidcRPMetaDataExportedVars) { + state.data.config.oidcRPMetaDataExportedVars = {}; + } + state.data.config.oidcRPMetaDataExportedVars[action.payload.appName] = + action.payload.data; + }, + newOidcRPMetaDataExportedVars(state, action: PayloadAction) { + if (!state.data.config.oidcRPMetaDataExportedVars) { + state.data.config.oidcRPMetaDataExportedVars = {}; + } + state.data.config.oidcRPMetaDataExportedVars[action.payload] = { + ...state.data.config.oidcRPMetaDataExportedVars[action.payload], + new: "", + }; + }, + delOidcRPMetaDataExportedVars( + state, + action: PayloadAction<{ appName: string; key: string }> + ) { + if (state.data.config.oidcRPMetaDataExportedVars) { + delete state.data.config.oidcRPMetaDataExportedVars[ + action.payload.appName + ][action.payload.key]; + } + }, + updateOidcMetaDataOptions( + state, + action: PayloadAction<{ + name: string; + option: string; + value: string | number; + }> + ) { + if (!state.data.config.oidcRPMetaDataOptions) { + state.data.config.samlSPMetaDataOptions = {}; + } + state.data.config.oidcRPMetaDataOptions[action.payload.name][ + action.payload.option + ] = action.payload.value; + }, + updateOidcRPMetaDataOptionsExtraClaims( + state, + action: PayloadAction<{ appName: string; data: Record }> + ) { + if (!state.data.config.oidcRPMetaDataOptionsExtraClaims) { + state.data.config.oidcRPMetaDataOptionsExtraClaims = {}; + } + state.data.config.oidcRPMetaDataOptionsExtraClaims[ + action.payload.appName + ] = action.payload.data; + }, + newOidcRPMetaDataOptionsExtraClaims(state, action: PayloadAction) { + if (!state.data.config.oidcRPMetaDataOptionsExtraClaims) { + state.data.config.oidcRPMetaDataOptionsExtraClaims = {}; + } + state.data.config.oidcRPMetaDataOptionsExtraClaims[action.payload] = { + ...state.data.config.oidcRPMetaDataOptionsExtraClaims[action.payload], + new: "", + }; + }, + delOidcRPMetaDataOptionsExtraClaims( + state, + action: PayloadAction<{ name: string; key: string }> + ) { + if (state.data.config.oidcRPMetaDataOptionsExtraClaims) { + delete state.data.config.oidcRPMetaDataOptionsExtraClaims[ + action.payload.name + ][action.payload.key]; + } + }, + updateOidcRPMetaDataScopeRules( + state, + action: PayloadAction<{ appName: string; data: Record }> + ) { + if (!state.data.config.oidcRPMetaDataScopeRules) { + state.data.config.oidcRPMetaDataScopeRules = {}; + } + state.data.config.oidcRPMetaDataScopeRules[action.payload.appName] = + action.payload.data; + }, + newOidcRPMetaDataScopeRules(state, action: PayloadAction) { + if (!state.data.config.oidcRPMetaDataScopeRules) { + state.data.config.oidcRPMetaDataScopeRules = {}; + } + state.data.config.oidcRPMetaDataScopeRules[action.payload] = { + ...state.data.config.oidcRPMetaDataScopeRules[action.payload], + new: "", + }; + }, + delOidcRPMetaDataScopeRules( + state, + action: PayloadAction<{ name: string; key: string }> + ) { + if (state.data.config.oidcRPMetaDataScopeRules) { + delete state.data.config.oidcRPMetaDataScopeRules[action.payload.name][ + action.payload.key + ]; + } + }, + updateOidcRPMetaDataOptionsJwks( + state, + action: PayloadAction<{ name: string; data: string }> + ) { + state.data.config.oidcRPMetaDataOptions[ + action.payload.name + ].oidcRPMetaDataOptionsJwks = action.payload.data; + }, }, extraReducers: (builder) => { builder @@ -536,5 +713,19 @@ export const { newSamlSPMetadataExportedAttribute, delSamlSPMetadataExportedAttribute, updateSamlMetaDataOptions, + newOIDCRPMetaDataMacros, + updateOIDCRPMetaDataMacros, + delOIDCRPMetaDataMacros, + updateOidcRPMetaDataExportedVars, + newOidcRPMetaDataExportedVars, + delOidcRPMetaDataExportedVars, + updateOidcMetaDataOptions, + delOidcRPMetaDataOptionsExtraClaims, + newOidcRPMetaDataOptionsExtraClaims, + updateOidcRPMetaDataOptionsExtraClaims, + newOidcRPMetaDataScopeRules, + delOidcRPMetaDataScopeRules, + updateOidcRPMetaDataScopeRules, + updateOidcRPMetaDataOptionsJwks, } = configSlice.actions; export default configSlice.reducer;