From 78136ceb390944644a0558d3469783b7faf5b828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Banno-Cloutier?= <leo.banno-cloutier@savoirfairelinux.com> Date: Tue, 27 Jun 2023 10:44:09 -0400 Subject: [PATCH] jams-react-client: fix a lot of runtime errors Change-Id: Iaf2a3be80203eba59fcbe9ccee10db6b91085213 --- Dockerfile | 2 +- README.md | 2 + .../authmodule/UserAuthenticationModule.java | 10 +- jams-react-client/jsconfig.json | 11 +- .../src/components/CaSetup/CaSetup.js | 7 +- .../src/components/CustomButtons/Button.js | 2 +- .../src/components/FormikField/FormikField.js | 12 +- .../ServerParameters/ServerParameters.js | 3 +- .../src/components/Sidebar/Sidebar.js | 64 ++++------ jams-react-client/src/index.js | 62 +++++----- jams-react-client/src/layouts/BaseLayout.js | 3 +- jams-react-client/src/tools.js | 2 +- .../src/views/Blueprints/Blueprints.js | 15 +-- jams-react-client/src/views/Groups/Groups.js | 112 +++++++++--------- .../src/views/Settings/General.js | 18 +-- .../src/views/Settings/Settings.js | 2 +- .../src/views/Settings/Subscription.js | 2 +- .../views/UserProfile/DisplayUserProfile.js | 2 +- .../UserProfile/EditCreateUserProfile.js | 3 +- .../src/views/UserProfile/UserProfile.js | 2 +- jams-react-client/src/views/Users/Users.js | 2 +- .../server/servlets/filters/FilterUtils.java | 65 +++++----- 22 files changed, 196 insertions(+), 207 deletions(-) diff --git a/Dockerfile b/Dockerfile index 77c4353f..2838d50e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ COPY . . FROM build as dev WORKDIR /app RUN mkdir -p /app/jams-server/src/main/resources/webapp \ - && echo '<h1>Dev build, please connect to <a href="http://localhost:3000">localhost:3000</a> instead</h1>' \ + && echo '<h1>Dev build, this is a placeholder index.html. Please connect to <a href="http://localhost:3000">localhost:3000</a> instead</h1>' \ > /app/jams-server/src/main/resources/webapp/index.html RUN mvn package WORKDIR /app/jams diff --git a/README.md b/README.md index 8446ea36..f8ec216c 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ The following commands will generate the userguide and the jars needed: docker build -f Dockerfile -t jams:latest --target prod . docker run -v $(pwd)/jams:/jams --rm jams:latest sudo chown -R $(whoami) jams +cd jams +java -jar jams-launcher.jar ``` ## About jams-server/src/main/java/net/jami/jams/server/filters diff --git a/authentication-module/src/main/java/net/jami/jams/authmodule/UserAuthenticationModule.java b/authentication-module/src/main/java/net/jami/jams/authmodule/UserAuthenticationModule.java index b0fcb15f..d9200353 100644 --- a/authentication-module/src/main/java/net/jami/jams/authmodule/UserAuthenticationModule.java +++ b/authentication-module/src/main/java/net/jami/jams/authmodule/UserAuthenticationModule.java @@ -100,10 +100,14 @@ public class UserAuthenticationModule implements AuthenticationModule { log.info("Succesfully stored OAuth public key for future use..."); } else{ - InputStream path; - privateKey = X509Utils.getKeyFromPEMString(new String(new FileInputStream(privateKeyFile).readAllBytes())); + InputStream privateInput = new FileInputStream(privateKeyFile); + privateKey = X509Utils.getKeyFromPEMString(new String(privateInput.readAllBytes())); + privateInput.close(); log.info("Succesfully loaded OAuth private key!"); - publicKey = X509Utils.getPubKeyFromPEMString(new String(new FileInputStream(pubkeyFile).readAllBytes())); + + InputStream publicInput = new FileInputStream(pubkeyFile); + publicKey = X509Utils.getPubKeyFromPEMString(new String(publicInput.readAllBytes())); + publicInput.close(); log.info("Succesfully loaded OAuth public key!"); } //TODO: Read signing key, if file does not exist create it (also create the corresponding public key) diff --git a/jams-react-client/jsconfig.json b/jams-react-client/jsconfig.json index dfc814cf..a4b71542 100644 --- a/jams-react-client/jsconfig.json +++ b/jams-react-client/jsconfig.json @@ -3,8 +3,13 @@ "jsx": "react", "baseUrl": "src", "paths": { - "*": ["./src/*"] + "*": [ + "./src/*" + ] }, "checkJs": true - } -} + }, + "include": [ + "src" + ] +} \ No newline at end of file diff --git a/jams-react-client/src/components/CaSetup/CaSetup.js b/jams-react-client/src/components/CaSetup/CaSetup.js index 8a13a009..647f6895 100644 --- a/jams-react-client/src/components/CaSetup/CaSetup.js +++ b/jams-react-client/src/components/CaSetup/CaSetup.js @@ -235,7 +235,7 @@ export default function CaSetup(props) { <CountrySelect defaultValue={values.country} {...props} /> {touched.country && errors.country ? ( - <span class="spanError">{errors.country}</span> + <span className="spanError">{errors.country}</span> ) : null} <TextField @@ -308,7 +308,6 @@ export default function CaSetup(props) { <Select labelId="validity-period-select-label" - margin="normal" fullWidth variant="outlined" value={validityPeriod.value} @@ -375,7 +374,7 @@ export default function CaSetup(props) { /> {form.errors.certificatefile && form.touched.certificatefile ? ( - <span class="spanError"> + <span className="spanError"> {form.errors.certificatefile} </span> ) : null} @@ -390,7 +389,7 @@ export default function CaSetup(props) { <div> <Input fullWidth type="file" {...field} /> {meta.touched && meta.error && ( - <span class="spanError">{meta.error}</span> + <span className="spanError">{meta.error}</span> )} </div> )} diff --git a/jams-react-client/src/components/CustomButtons/Button.js b/jams-react-client/src/components/CustomButtons/Button.js index 166cb8e8..09ab8f2d 100644 --- a/jams-react-client/src/components/CustomButtons/Button.js +++ b/jams-react-client/src/components/CustomButtons/Button.js @@ -58,7 +58,7 @@ RegularButton.propTypes = { "white", "transparent", ]), - size: PropTypes.oneOf(["sm", "lg"]), + size: PropTypes.oneOf(["small", "large"]), simple: PropTypes.bool, round: PropTypes.bool, disabled: PropTypes.bool, diff --git a/jams-react-client/src/components/FormikField/FormikField.js b/jams-react-client/src/components/FormikField/FormikField.js index be464b67..6692bb87 100644 --- a/jams-react-client/src/components/FormikField/FormikField.js +++ b/jams-react-client/src/components/FormikField/FormikField.js @@ -47,16 +47,16 @@ class FormikField extends React.Component { } FormikField.propTypes = { - startAdornment: false, - endAdornment: false, + startAdornment: PropTypes.element, + endAdornment: PropTypes.element, placeholder: PropTypes.string, - required: false, + required: PropTypes.bool, name: PropTypes.string.isRequired, label: PropTypes.string.isRequired, - type: "text", - autoComplete: "on", + type: PropTypes.string, + autoComplete: PropTypes.oneOf(["on", "off"]), handleChange: PropTypes.func, - onKeyUpError: false, + onKeyUpError: PropTypes.bool, onKeyUpErrorMessage: PropTypes.string, }; diff --git a/jams-react-client/src/components/ServerParameters/ServerParameters.js b/jams-react-client/src/components/ServerParameters/ServerParameters.js index 8063a05b..18451c0c 100644 --- a/jams-react-client/src/components/ServerParameters/ServerParameters.js +++ b/jams-react-client/src/components/ServerParameters/ServerParameters.js @@ -265,12 +265,11 @@ export default function ServerParameters(props) { fullWidth value={userAccountLifetime.value} onChange={handleUserAccountLifetimeChange} - isDisabled={userlifeDisabled} variant="outlined" children={userAccountLifetimeTypesItems} /> {userlifeDisabled ? ( - <span class="spanError"> + <span className="spanError"> {i18next.t( "account_lifetime_should_be_bigger_to_device_lifetime", "The account lifetime should be longer than the Device lifetime." diff --git a/jams-react-client/src/components/Sidebar/Sidebar.js b/jams-react-client/src/components/Sidebar/Sidebar.js index 7166b0a0..7193525a 100755 --- a/jams-react-client/src/components/Sidebar/Sidebar.js +++ b/jams-react-client/src/components/Sidebar/Sidebar.js @@ -2,7 +2,6 @@ import React, { useEffect, useState } from "react"; import { Link, useHistory } from "react-router-dom"; import classNames from "classnames"; import PropTypes from "prop-types"; -import { NavLink } from "react-router-dom"; // @material-ui/core components import { makeStyles } from "@material-ui/core/styles"; @@ -82,47 +81,32 @@ export default function Sidebar(props) { ></Snackbar> )} - <NavLink - to={prop.layout + prop.path} - className={classes.item} - activeClassName="active" - key={key} - > - <Link to={`${prop.path}`}> - <ListItem button className={classes.itemLink + listItemClasses}> - {typeof prop.icon === "string" ? ( - <Icon - className={classNames( - classes.itemIcon, - whiteFontClasses, - { - [classes.itemIconRTL]: props.rtlActive, - } - )} - > - {prop.icon} - </Icon> - ) : ( - <prop.icon - className={classNames( - classes.itemIcon, - whiteFontClasses, - { - [classes.itemIconRTL]: props.rtlActive, - } - )} - /> - )} - <ListItemText - primary={props.rtlActive ? prop.rtlName : prop.name} - className={classNames(classes.itemText, whiteFontClasses, { - [classes.itemTextRTL]: props.rtlActive, + <Link to={`${prop.path}`}> + <ListItem button className={classes.itemLink + listItemClasses}> + {typeof prop.icon === "string" ? ( + <Icon + className={classNames(classes.itemIcon, whiteFontClasses, { + [classes.itemIconRTL]: props.rtlActive, + })} + > + {prop.icon} + </Icon> + ) : ( + <prop.icon + className={classNames(classes.itemIcon, whiteFontClasses, { + [classes.itemIconRTL]: props.rtlActive, })} - disableTypography={true} /> - </ListItem> - </Link> - </NavLink> + )} + <ListItemText + primary={props.rtlActive ? prop.rtlName : prop.name} + className={classNames(classes.itemText, whiteFontClasses, { + [classes.itemTextRTL]: props.rtlActive, + })} + disableTypography={true} + /> + </ListItem> + </Link> </div> ); })} diff --git a/jams-react-client/src/index.js b/jams-react-client/src/index.js index 28c6f538..7865c818 100644 --- a/jams-react-client/src/index.js +++ b/jams-react-client/src/index.js @@ -64,33 +64,41 @@ auth.checkServerInstalled(() => { auth.checkAdminAccountStatus(() => { auth.checkLastKnownStep(() => { ReactDOM.render( - <ThemeProvider theme={theme}> - <Suspense fallback={<div>Loading...</div>}> - <Router history={hist}> - <Switch> - <ConfiguredRoute path="/signin" component={SignIn} /> - <ProtectedRoute path="/users" component={UsersRoute} /> - <ProtectedRoute path="/user/:username" component={UserRoute} /> - <ProtectedRoute - path="/createuser" - component={CreateUserRoute} - /> - <ProtectedRoute path="/groups" component={GroupsRoute} /> - <ProtectedRoute path="/group/:groupid" component={GroupRoute} /> - <ProtectedRoute - path="/blueprints" - component={BlueprintsRoute} - /> - <ProtectedRoute - path="/blueprint/:blueprintname" - component={BlueprintRoute} - /> - <ProtectedRoute path="/settings" component={SettingsRoute} /> - <Redirect from="/" to="/signin" /> - </Switch> - </Router> - </Suspense> - </ThemeProvider>, + <StrictMode> + <ThemeProvider theme={theme}> + <Suspense fallback={<div>Loading...</div>}> + <Router history={hist}> + <Switch> + <ConfiguredRoute path="/signin" component={SignIn} /> + <ProtectedRoute path="/users" component={UsersRoute} /> + <ProtectedRoute + path="/user/:username" + component={UserRoute} + /> + <ProtectedRoute + path="/createuser" + component={CreateUserRoute} + /> + <ProtectedRoute path="/groups" component={GroupsRoute} /> + <ProtectedRoute + path="/group/:groupid" + component={GroupRoute} + /> + <ProtectedRoute + path="/blueprints" + component={BlueprintsRoute} + /> + <ProtectedRoute + path="/blueprint/:blueprintname" + component={BlueprintRoute} + /> + <ProtectedRoute path="/settings" component={SettingsRoute} /> + <Redirect from="/" to="/signin" /> + </Switch> + </Router> + </Suspense> + </ThemeProvider> + </StrictMode>, document.getElementById("root") ); }); diff --git a/jams-react-client/src/layouts/BaseLayout.js b/jams-react-client/src/layouts/BaseLayout.js index 31478b81..4919d244 100644 --- a/jams-react-client/src/layouts/BaseLayout.js +++ b/jams-react-client/src/layouts/BaseLayout.js @@ -40,6 +40,7 @@ import DialogContentText from "@material-ui/core/DialogContentText/DialogContent import Button from "@material-ui/core/Button"; import i18next from "i18next"; +import { AccountCircle as AccountCircleIcon } from "@material-ui/icons"; let ps; @@ -66,7 +67,7 @@ export default function Admin(props) { { path: `/user/${auth.getUsername()}`, name: i18next.t("myprofile", "My profile"), - icon: Person, + icon: AccountCircleIcon, component: Users, layout: "/admin", }, diff --git a/jams-react-client/src/tools.js b/jams-react-client/src/tools.js index ba579019..eb0cec13 100644 --- a/jams-react-client/src/tools.js +++ b/jams-react-client/src/tools.js @@ -2,7 +2,7 @@ import React from "react"; import MenuItem from "@material-ui/core/MenuItem"; export function buildSelectMenuItems(elements) { - return elements.map((d) => <MenuItem value={d.value}>{d.label}</MenuItem>); + return elements.map((d) => <MenuItem key={d.value} value={d.value}>{d.label}</MenuItem>); } // read file content diff --git a/jams-react-client/src/views/Blueprints/Blueprints.js b/jams-react-client/src/views/Blueprints/Blueprints.js index 239784f7..c907f861 100644 --- a/jams-react-client/src/views/Blueprints/Blueprints.js +++ b/jams-react-client/src/views/Blueprints/Blueprints.js @@ -88,15 +88,12 @@ export default function Blueprints() { const classes = useStyles(); const history = useHistory(); const [blueprints, setBlueprints] = useState([]); - const [selectedBlueprint, setSelectedBlueprint] = useState(false); - const [selectedBlueprintName, setSelectedBlueprintName] = useState(""); const [loading, setLoading] = useState(false); const [zeroBlueprint, setZeroBlueprint] = useState(false); const [progress, setProgress] = useState(0); - const [searchValue, setSearchValue] = useState(false); const [blueprintName, setBlueprintName] = useState(""); - const [blueprintNameExits, setBlueprintNameExits] = useState(); + const [blueprintNameExits, setBlueprintNameExits] = useState(false); const [open, setOpen] = useState(false); const [disableCreate, setDisableCreate] = useState(true); @@ -105,6 +102,7 @@ export default function Blueprints() { const [openRemoveDialog, setOpenRemoveDialog] = useState(false); useEffect(() => { + console.log("useEffect"); setLoading(true); const timer = setInterval(() => { setProgress((oldProgress) => { @@ -135,12 +133,6 @@ export default function Blueprints() { }; }, [history, open, openRemoveDialog]); - function redirectToBlueprint(e, blueprintNameRedirect) { - e.preventDefault(); - setSelectedBlueprint(true); - setSelectedBlueprintName(blueprintNameRedirect); - } - const handleCheckBlueprintNameExists = (searchBlueprintNameValue) => { setDisableCreate(true); axios( @@ -202,8 +194,6 @@ export default function Blueprints() { .then((response) => { setOpen(false); setDisableCreate(true); - setSelectedBlueprintName(blueprintName); - setSelectedBlueprint(true); console.log("Successfully created " + blueprintName); }) .catch((error) => { @@ -356,7 +346,6 @@ export default function Blueprints() { "Search blueprints" ), }, - onKeyUp: (e) => setSearchValue(e.target.value), }} /> )} diff --git a/jams-react-client/src/views/Groups/Groups.js b/jams-react-client/src/views/Groups/Groups.js index 0ad1ce74..d4846e6b 100644 --- a/jams-react-client/src/views/Groups/Groups.js +++ b/jams-react-client/src/views/Groups/Groups.js @@ -320,65 +320,63 @@ export default function Groups() { {i18next.t("create_group", "Create group")} </DialogTitle> <DialogContent> - <DialogContentText id="alert-dialog-description"> - <Grid container spacing={2}> - <Grid item xs={12} sm={12} md={12}> - <FormControl - className={classes.margin} - error={groupNameExits} - fullWidth - > - <InputLabel htmlFor="groupName"> - {i18next.t("group_name", "Group name")} - </InputLabel> - <Input - id="groupName" - placeholder={i18next.t("group_name", "Group name")} - startAdornment={ - <InputAdornment position="start"> - <PeopleOutlineIcon /> - </InputAdornment> - } - onChange={(e) => { - setGroupName(e.target.value); - initCheckGroupNameExists(e.target.value); - }} - /> - </FormControl> - {disableCreate && groupName.length > 0 && ( - <p> - {i18next.t( - "group_name_already_exists", - "Group name already exists!" - )} - </p> - )} - {disableCreate && groupName.length === 0 && ( - <p> - {i18next.t("group_name_is_empty", "Group name is empty")} - </p> - )} - </Grid> - <Grid item xs={12} sm={12} md={12}> - <InputLabel - className={classes.inputBottomMargin} - htmlFor="blueprint" - > - {i18next.t("select_blueprint", "Select a blueprint")} + <Grid container spacing={2}> + <Grid item xs={12} sm={12} md={12}> + <FormControl + className={classes.margin} + error={groupNameExits} + fullWidth + > + <InputLabel htmlFor="groupName"> + {i18next.t("group_name", "Group name")} </InputLabel> - <Select - labelId="demo-simple-select-label" - fullWidth - value={selectedBlueprint.value} - onChange={handleBlueprintsChange} - variant="outlined" - disabled={blueprints.length === 0} - > - {blueprintsOptionsItems} - </Select> - </Grid> + <Input + id="groupName" + placeholder={i18next.t("group_name", "Group name")} + startAdornment={ + <InputAdornment position="start"> + <PeopleOutlineIcon /> + </InputAdornment> + } + onChange={(e) => { + setGroupName(e.target.value); + initCheckGroupNameExists(e.target.value); + }} + /> + </FormControl> + {disableCreate && groupName.length > 0 && ( + <p> + {i18next.t( + "group_name_already_exists", + "Group name already exists!" + )} + </p> + )} + {disableCreate && groupName.length === 0 && ( + <p> + {i18next.t("group_name_is_empty", "Group name is empty")} + </p> + )} </Grid> - </DialogContentText> + <Grid item xs={12} sm={12} md={12}> + <InputLabel + className={classes.inputBottomMargin} + htmlFor="blueprint" + > + {i18next.t("select_blueprint", "Select a blueprint")} + </InputLabel> + <Select + labelId="demo-simple-select-label" + fullWidth + value={selectedBlueprint.value} + onChange={handleBlueprintsChange} + variant="outlined" + disabled={blueprints.length === 0} + > + {blueprintsOptionsItems} + </Select> + </Grid> + </Grid> </DialogContent> <DialogActions> <Button onClick={handleCloseCreate} color="primary"> diff --git a/jams-react-client/src/views/Settings/General.js b/jams-react-client/src/views/Settings/General.js index be1190eb..bb82b6ca 100644 --- a/jams-react-client/src/views/Settings/General.js +++ b/jams-react-client/src/views/Settings/General.js @@ -108,10 +108,12 @@ export default function General(props) { password: Yup.string().required( i18next.t("password_is_required", "Password is required!") ), - confirmPassword: Yup.string().oneOf( - [Yup.ref("password"), null], - i18next.t("password_must_match", "Passwords must match") - ), + confirmPassword: Yup.string() + .oneOf( + [Yup.ref("password")], + i18next.t("password_must_match", "Passwords must match") + ) + .required(i18next.t("password_is_required", "Password is required!")), }); const handleMouseDownPassword = () => { @@ -147,7 +149,7 @@ export default function General(props) { <form onSubmit={handleSubmit} className={classes.form}> <Grid container spacing={2}> <Grid item lg={6} style={{ display: "flex" }}> - <Typography variant="p" gutterBottom color="primary"> + <Typography component="p" gutterBottom color="primary"> {i18next.t("change_language", "Change language")} </Typography> </Grid> @@ -155,7 +157,7 @@ export default function General(props) { <LanguagePicker navigationTarget={"/admin/settings"} /> </Grid> <Grid item lg={6}> - <Typography variant="p" gutterBottom color="primary"> + <Typography component="p" gutterBottom color="primary"> {i18next.t( "enter_the_following_information_below_to_change_your_admin_password", "Enter the following information to change your admin password." @@ -233,7 +235,6 @@ export default function General(props) { <Button variant="contained" - color="info" size="large" className={classes.button} startIcon={<RefreshIcon />} @@ -264,7 +265,6 @@ export default function General(props) { > <Button variant="contained" - color="info" size="large" className={classes.button} startIcon={<FileCopyIcon />} @@ -290,7 +290,7 @@ export default function General(props) { variant="contained" color="primary" fullWidth - disable={!isValid && !dirty} + disabled={!isValid || !dirty} className={classes.submit} > {i18next.t( diff --git a/jams-react-client/src/views/Settings/Settings.js b/jams-react-client/src/views/Settings/Settings.js index 60b331e1..09f4dae7 100644 --- a/jams-react-client/src/views/Settings/Settings.js +++ b/jams-react-client/src/views/Settings/Settings.js @@ -30,7 +30,7 @@ function TabPanel(props) { > {value === index && ( <Box p={3}> - <Typography>{children}</Typography> + <Typography component="div">{children}</Typography> </Box> )} </div> diff --git a/jams-react-client/src/views/Settings/Subscription.js b/jams-react-client/src/views/Settings/Subscription.js index 3b55b3d0..32745f8a 100644 --- a/jams-react-client/src/views/Settings/Subscription.js +++ b/jams-react-client/src/views/Settings/Subscription.js @@ -141,7 +141,7 @@ export default function Subscription(props) { > <Grid container spacing={3}> <Grid item lg={6}> - <Typography variant="p" gutterBottom color="primary"> + <Typography component="p" gutterBottom color="primary"> {i18next.t( "paste_your_jams_enterprise_subscription_code_received_from_jami", "Paste your JAMS Enterprise subscription code received from the Jami store." diff --git a/jams-react-client/src/views/UserProfile/DisplayUserProfile.js b/jams-react-client/src/views/UserProfile/DisplayUserProfile.js index 519ed68c..188e3c4f 100644 --- a/jams-react-client/src/views/UserProfile/DisplayUserProfile.js +++ b/jams-react-client/src/views/UserProfile/DisplayUserProfile.js @@ -198,7 +198,7 @@ const useStyles = makeStyles(styles); export default function DisplayUserProfile(props) { const classes = useStyles(); const history = useHistory(); - const [user, setUser] = useState([]); + const [user, setUser] = useState({}); const [groupMemberships, setGroupMemberships] = useState([]); const [revoked, setRevoked] = useState(false); const [open, setOpen] = useState(false); diff --git a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js index 58b3e3d6..0c4ca594 100644 --- a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js +++ b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js @@ -664,7 +664,6 @@ export default function EditCreateUserProfile(props) { <label htmlFor="icon-button-file"> <IconButton id="change-profile-picture" - color="info" aria-label="upload picture" component="span" > @@ -689,7 +688,7 @@ export default function EditCreateUserProfile(props) { } endAdornment={ values.username === "" ? ( - "" + null ) : userExists ? ( <CancelIcon style={{ color: "#cc0000" }} /> ) : ( diff --git a/jams-react-client/src/views/UserProfile/UserProfile.js b/jams-react-client/src/views/UserProfile/UserProfile.js index a84be1bb..16575b4b 100755 --- a/jams-react-client/src/views/UserProfile/UserProfile.js +++ b/jams-react-client/src/views/UserProfile/UserProfile.js @@ -32,7 +32,7 @@ function TabPanel(props) { > {value === index && ( <Box p={3}> - <Typography>{children}</Typography> + <Typography component="div">{children}</Typography> </Box> )} </div> diff --git a/jams-react-client/src/views/Users/Users.js b/jams-react-client/src/views/Users/Users.js index 15723108..1b7740a3 100644 --- a/jams-react-client/src/views/Users/Users.js +++ b/jams-react-client/src/views/Users/Users.js @@ -272,7 +272,7 @@ export default function Users(props) { <GridContainer container direction="column" - justify="flex-end" + justifyContent="flex-end" alignItems="flex-start" > <GridItem style={{ minHeight: "50px" }}> diff --git a/jams-server/src/main/java/net/jami/jams/server/servlets/filters/FilterUtils.java b/jams-server/src/main/java/net/jami/jams/server/servlets/filters/FilterUtils.java index abc69c17..0209bd95 100644 --- a/jams-server/src/main/java/net/jami/jams/server/servlets/filters/FilterUtils.java +++ b/jams-server/src/main/java/net/jami/jams/server/servlets/filters/FilterUtils.java @@ -69,43 +69,44 @@ public class FilterUtils { public static boolean doAuthCheck(HttpServletRequest request){ AuthRequestType requestType = FilterUtils.classifyRequest(request); + if (requestType == null) { + return false; + } try { - if (requestType != null) { - SignedJWT token = null; - switch (requestType) { - case BASIC: - token = SignedJWT.parse(processUsernamePasswordAuth(request.getHeader("authorization")).getAccess_token()); - break; - case BEARER_TOKEN: - token = SignedJWT.parse(request.getHeader("authorization"). - replace("bearer", "") - .replace("Bearer", "")); - break; - default: - return false; - } - StatementList statementList = new StatementList(); - StatementElement statementElement = new StatementElement("username", "=", token.getJWTClaimsSet().getSubject(), ""); - statementList.addStatement(statementElement); - log.info("Getting user from database"); - User user = dataStore.getUserDao().getObjects(statementList).get(0); - log.info("User retrieved from database: {}", user); - if(!user.getAccessLevelName().equals("ADMIN") && certificateAuthority.getLatestCRL().get() != null) { - if(certificateAuthority.getLatestCRL().get().getRevokedCertificate(user.getCertificate().getSerialNumber()) != null) - return false; - } - JWSVerifier jwsVerifier = new RSASSAVerifier(userAuthenticationModule.getAuthModulePubKey()); - if (token.verify(jwsVerifier) && verifyValidity(token)) { - request.setAttribute(USERNAME_ATTR, token.getJWTClaimsSet().getSubject()); - request.setAttribute(ACCESS_LEVEL_ATTR, AccessLevel.valueOf(token.getJWTClaimsSet().getClaim("scope").toString())); - return true; - } + SignedJWT token = null; + switch (requestType) { + case BASIC: + token = SignedJWT.parse(processUsernamePasswordAuth(request.getHeader("authorization")).getAccess_token()); + break; + case BEARER_TOKEN: + token = SignedJWT.parse(request.getHeader("authorization"). + replace("bearer", "") + .replace("Bearer", "")); + break; + default: + return false; + } + StatementList statementList = new StatementList(); + StatementElement statementElement = new StatementElement("username", "=", token.getJWTClaimsSet().getSubject(), ""); + statementList.addStatement(statementElement); + log.info("Getting user from database"); + User user = dataStore.getUserDao().getObjects(statementList).get(0); + log.info("User retrieved from database: {}", user); + if(!user.getAccessLevelName().equals("ADMIN") && certificateAuthority.getLatestCRL().get() != null) { + if(certificateAuthority.getLatestCRL().get().getRevokedCertificate(user.getCertificate().getSerialNumber()) != null) + return false; + } + JWSVerifier jwsVerifier = new RSASSAVerifier(userAuthenticationModule.getAuthModulePubKey()); + if (token.verify(jwsVerifier) && verifyValidity(token)) { + request.setAttribute(USERNAME_ATTR, token.getJWTClaimsSet().getSubject()); + request.setAttribute(ACCESS_LEVEL_ATTR, AccessLevel.valueOf(token.getJWTClaimsSet().getClaim("scope").toString())); + return true; } - return false; } catch (Exception e){ log.info("Failed to process authentication request and denying access: {}",e.getMessage()); - return false; } + + return false; } } -- GitLab