Fixed issue where authentication header is not set properly every time

This commit is contained in:
frikky
2022-06-05 21:47:48 +02:00
parent 387731fbfe
commit 82ae7c2ae0
2 changed files with 28 additions and 12 deletions
+1 -1
View File
@@ -856,7 +856,7 @@ const Header = (props) => {
position: "fixed", position: "fixed",
minHeight: 60, minHeight: 60,
top: 0, top: 0,
//zIndex: 10000, zIndex: 10000,
backgroundColor: "inherit", backgroundColor: "inherit",
}} }}
> >
+27 -11
View File
@@ -289,8 +289,8 @@ const AppCreator = (defaultprops) => {
type: "header", type: "header",
example: "", example: "",
}; };
const [extraAuth, setExtraAuth] = useState([]);
const [extraAuth, setExtraAuth] = useState([]);
const [app, setApp] = useState({}); const [app, setApp] = useState({});
const [appAuthentication, setAppAuthentication] = React.useState([]); const [appAuthentication, setAppAuthentication] = React.useState([]);
const [selectedAction, setSelectedAction] = useState({}); const [selectedAction, setSelectedAction] = useState({});
@@ -1420,6 +1420,8 @@ const AppCreator = (defaultprops) => {
//console.log("SECURITYSCHEMES: ", securitySchemes) //console.log("SECURITYSCHEMES: ", securitySchemes)
if (securitySchemes !== undefined) { if (securitySchemes !== undefined) {
console.log("NEWAUTH: ", securitySchemes)
var valueset = false
// FIXME: Should add Oauth2 (Microsoft) and JWT (Wazuh) // FIXME: Should add Oauth2 (Microsoft) and JWT (Wazuh)
//console.log("SECURITY: ", securitySchemes) //console.log("SECURITY: ", securitySchemes)
//if (Object.entries(securitySchemes) > 1 && //if (Object.entries(securitySchemes) > 1 &&
@@ -1444,18 +1446,31 @@ const AppCreator = (defaultprops) => {
setAuthenticationRequired(true); setAuthenticationRequired(true);
} else if (key === "ApiKeyAuth" || key === "Token" || ((value.in === "header" || value.in === "query") && value.name !== undefined)) { } else if (key === "ApiKeyAuth" || key === "Token" || ((value.in === "header" || value.in === "query") && value.name !== undefined)) {
setAuthenticationOption("API key"); if (authenticationOption === "" || authenticationOption === "No authentication") {
setAuthenticationOption("API key");
}
value.in = value.in.charAt(0).toUpperCase() + value.in.slice(1); if (valueset === false) {
setParameterLocation(value.in); valueset = true
if (!apikeySelection.includes(value.in)) { value.in = value.in.charAt(0).toUpperCase() + value.in.slice(1)
console.log("APIKEY SELECT: ", apikeySelection);
alert.error("Might be error in setting up API key authentication");
}
console.log("PARAM NAME: ", value.name); setParameterLocation(value.in);
setParameterName(value.name); if (!apikeySelection.includes(value.in)) {
setAuthenticationRequired(true); console.log("APIKEY SELECT: ", apikeySelection);
alert.error("Might be error in setting up API key authentication");
}
console.log("PARAM NAME: ", value.name);
setParameterName(value.name);
setAuthenticationRequired(true);
} else {
newauth.push({
"name": key,
"type": value.in.toLowerCase(),
"in": value.in.toLowerCase(),
"example": "",
})
}
if (value.description !== undefined && value.description !== null && value.description.length > 0) { if (value.description !== undefined && value.description !== null && value.description.length > 0) {
// Don't want a real description - just the ones we're replacing with // Don't want a real description - just the ones we're replacing with
@@ -2365,6 +2380,7 @@ const AppCreator = (defaultprops) => {
<span style={{ width: 50 }} /> <span style={{ width: 50 }} />
)} )}
</div> </div>
{extraAuth.map((value, index) => { {extraAuth.map((value, index) => {
return ( return (
<span <span