diff --git a/Dockerfile b/Dockerfile index 77c4353f161714c9f86bdc4c6f34bba65011fad6..2838d50eb0b7fe5157bb6cee01a60a04ea428b74 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 8446ea3632dd8550a48766ca356d6d943315bdfd..f8ec216ccbe752f97f607196871bbc25b7eca22b 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 b0fcb15fd1cbb3416878df2b1daa498c7262c01d..d9200353660c5b1c9d9214c2dc44276a110f3856 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 dfc814cff736201952793884d4f464c5ebfd0f5b..a4b71542a6c88c77936f3e89f2248578ecb9eb57 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 8a13a009aef10da96a6d9bfa0906d7522b9a352c..647f68957d744625a9e356b776d54d38f8987fbe 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 166cb8e85095ac15b05baa782518381f8aa652fd..09ab8f2d53c9b0498f65799e87f2d504374039dc 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 be464b677619da7e874ba382cec1e38b54acf24a..6692bb8761b00dacd850d83c11730dc09994f673 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 8063a05b83ba1ed318728a6c9b57d45546357196..18451c0c165413b53cfe97225e060401eb09a8f7 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 7166b0a0c9070ed00278457fb06a93c6970ee87a..7193525a24a329a7e881c32a6cdbfeec6b03fbe1 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 28c6f53895216d69cd883afcd979401403599d86..7865c8188ca2052a85018e7b1ea473c822988504 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 31478b817c48ad7e9a810423da98f6f6c94d7a4e..4919d24471df14a877df840da35dd63634ac8be6 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 ba579019ea1f52c04ab95578e76d57a4d61513f3..eb0cec1340561e6636b4975c6fc4a5976dc2677a 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 239784f7e9ba1948ccaf72aef43ceaefdbb2bd65..c907f861d25a12f7852a1a2703912127d4a4036a 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 0ad1ce7479613af2894c58298d07584d14ed9645..d4846e6bcc70f386662df105484476135c8c6e38 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 be1190ebb5dc791c7e14da334a57def94b212753..bb82b6ca43b8d94b6bff459b462452c6b1083322 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 60b331e1e6db2295aa63d17107d74ddaed0467db..09f4dae72016413ee80e4d69309940dd645f99d0 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 3b55b3d00b637ced16e32edcacfa656a72fb1be0..32745f8a5467d9a0f8d86a25a193edec5d7273cf 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 519ed68cbf289d0a2936dc92fe8f6de48edcd998..188e3c4fb91dba02e78ade8ee2fba4019c0f9529 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 58b3e3d6f663ceb5db0d562a0ab0d97f69046dc3..0c4ca59493ddd964037503f490098edea7d84a67 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 a84be1bb29bc1ad2025ed38440df97c41657be47..16575b4ba18f41cc05d3607ee312a4b40c786f23 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 15723108808334c788adc2f05299e94a5424af5a..1b7740a33d1e0c4bffbe2195ad1a622c13cabab6 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 abc69c17f11a1fea4c750df5f9b086599bfde833..0209bd959ad66dfe2d87ff7d7cf8e322b51a96f0 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; } }