[ARVADOS-WORKBENCH2] created: 1.4.1-300-g09881155
Git user
git at public.arvados.org
Sun Mar 29 14:50:48 UTC 2020
at 09881155e1a7e253b73389e03d80d1e4efbee5f3 (commit)
commit 09881155e1a7e253b73389e03d80d1e4efbee5f3
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Sun Mar 29 11:50:01 2020 -0300
16212: Adds login form when PAM Login is enabled. (WIP)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/views-components/login-form/login-form.tsx b/src/views-components/login-form/login-form.tsx
new file mode 100644
index 00000000..404c91ff
--- /dev/null
+++ b/src/views-components/login-form/login-form.tsx
@@ -0,0 +1,128 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { useState, useEffect } from 'react';
+import { withStyles, WithStyles, StyleRulesCallback } from '@material-ui/core/styles';
+import CircularProgress from '@material-ui/core/CircularProgress';
+import { Button, Card, CardContent, TextField, CardActions } from '@material-ui/core';
+import { green } from '@material-ui/core/colors';
+import { AxiosPromise } from 'axios';
+
+type CssRules = 'root' | 'loginBtn' | 'card' | 'wrapper' | 'progress';
+
+const styles: StyleRulesCallback<CssRules> = theme => ({
+ root: {
+ display: 'flex',
+ flexWrap: 'wrap',
+ width: '100%',
+ margin: `${theme.spacing.unit} auto`
+ },
+ loginBtn: {
+ marginTop: theme.spacing.unit,
+ flexGrow: 1
+ },
+ card: {
+ marginTop: theme.spacing.unit,
+ width: '100%'
+ },
+ wrapper: {
+ margin: theme.spacing.unit,
+ position: 'relative',
+ },
+ progress: {
+ color: green[500],
+ position: 'absolute',
+ top: '50%',
+ left: '50%',
+ marginTop: -12,
+ marginLeft: -12,
+ },
+});
+
+interface LoginFormProps {
+ handleSubmit: (username: string, password: string) => AxiosPromise;
+}
+
+export const LoginForm = withStyles(styles)(
+ ({ handleSubmit, classes }: LoginFormProps & WithStyles<CssRules>) => {
+ const [username, setUsername] = useState('');
+ const [password, setPassword] = useState('');
+ const [isButtonDisabled, setIsButtonDisabled] = useState(true);
+ const [isSubmitting, setSubmitting] = useState(false);
+ const [helperText, setHelperText] = useState('');
+ const [error, setError] = useState(false);
+
+ useEffect(() => {
+ setError(false);
+ setHelperText('');
+ if (username.trim() && password.trim()) {
+ setIsButtonDisabled(false);
+ } else {
+ setIsButtonDisabled(true);
+ }
+ }, [username, password]);
+
+ const handleLogin = () => {
+ setSubmitting(true);
+ handleSubmit(username, password)
+ .then((response) => {
+ setError(false);
+ console.log("LOGIN SUCESSFUL: ", response);
+ setSubmitting(false);
+ })
+ .catch((err) => {
+ setError(true);
+ console.log("ERROR: ", err.response);
+ setHelperText(`${err.response && err.response.data && err.response.data.errors[0] || 'Error logging in: '+err}`);
+ setSubmitting(false);
+ });
+ };
+
+ const handleKeyPress = (e: any) => {
+ if (e.keyCode === 13 || e.which === 13) {
+ if (!isButtonDisabled) {
+ handleLogin();
+ }
+ }
+ };
+
+ return (
+ <React.Fragment>
+ <form className={classes.root} noValidate autoComplete="off">
+ <Card className={classes.card}>
+ <div className={classes.wrapper}>
+ <CardContent>
+ <div>
+ <TextField
+ disabled={isSubmitting}
+ error={error} fullWidth id="username" type="email"
+ label="Username" margin="normal"
+ onChange={(e) => setUsername(e.target.value)}
+ onKeyPress={(e) => handleKeyPress(e)}
+ />
+ <TextField
+ disabled={isSubmitting}
+ error={error} fullWidth id="password" type="password"
+ label="Password" margin="normal"
+ helperText={helperText}
+ onChange={(e) => setPassword(e.target.value)}
+ onKeyPress={(e) => handleKeyPress(e)}
+ />
+ </div>
+ </CardContent>
+ <CardActions>
+ <Button variant="contained" size="large" color="primary"
+ className={classes.loginBtn} onClick={() => handleLogin()}
+ disabled={isSubmitting || isButtonDisabled}>
+ Log in
+ </Button>
+ </CardActions>
+ { isSubmitting && <CircularProgress color='secondary' className={classes.progress} />}
+ </div>
+ </Card>
+ </form>
+ </React.Fragment>
+ );
+ });
diff --git a/src/views/login-panel/login-panel.tsx b/src/views/login-panel/login-panel.tsx
index 45f796fd..e7eadbad 100644
--- a/src/views/login-panel/login-panel.tsx
+++ b/src/views/login-panel/login-panel.tsx
@@ -9,6 +9,8 @@ import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/st
import { login, authActions } from '~/store/auth/auth-action';
import { ArvadosTheme } from '~/common/custom-theme';
import { RootState } from '~/store/store';
+import { LoginForm } from '~/views-components/login-form/login-form';
+import Axios from 'axios';
type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
@@ -47,12 +49,22 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
}
});
+const doPAMLogin = (url: string) => (username: string, password: string) => {
+ const formData = new FormData();
+ formData.append("username", username);
+ formData.append("password", password);
+ return Axios.post(`${url}/login`, formData, {
+ headers: { 'X-Http-Method-Override': 'GET' },
+ });
+};
+
type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
remoteHosts: { [key: string]: string },
homeCluster: string,
uuidPrefix: string,
loginCluster: string,
- welcomePage: string
+ welcomePage: string,
+ pamLogin: boolean,
};
export const LoginPanel = withStyles(styles)(
@@ -61,8 +73,9 @@ export const LoginPanel = withStyles(styles)(
homeCluster: state.auth.homeCluster,
uuidPrefix: state.auth.localCluster,
loginCluster: state.auth.loginCluster,
- welcomePage: state.auth.config.clusterConfig.Workbench.WelcomePageHTML
- }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix, loginCluster, welcomePage }: LoginPanelProps) =>
+ welcomePage: state.auth.config.clusterConfig.Workbench.WelcomePageHTML,
+ pamLogin: state.auth.config.clusterConfig.Login.PAM,
+ }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix, loginCluster, welcomePage, pamLogin }: LoginPanelProps) =>
<Grid container justify="center" alignItems="center"
className={classes.root}
style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
@@ -80,14 +93,19 @@ export const LoginPanel = withStyles(styles)(
</Select>
</Typography>}
- <Typography component="div" align="right">
- <Button variant="contained" color="primary" style={{ margin: "1em" }} className={classes.button}
+ {pamLogin
+ ? <Typography component="div">
+ <LoginForm handleSubmit={
+ doPAMLogin(`https://${remoteHosts[homeCluster]}`)}/>
+ </Typography>
+ : <Typography component="div" align="right">
+ <Button variant="contained" color="primary" style={{ margin: "1em" }}
+ className={classes.button}
onClick={() => dispatch(login(uuidPrefix, homeCluster, loginCluster, remoteHosts))}>
- Log in
- {uuidPrefix !== homeCluster && loginCluster !== homeCluster &&
+ Log in {uuidPrefix !== homeCluster && loginCluster !== homeCluster &&
<span> to {uuidPrefix} with user from {homeCluster}</span>}
</Button>
- </Typography>
+ </Typography>}
</Grid>
</Grid >
));
commit a00b325b40b61e180afdd04c801a82f0b7eb44e0
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Fri Mar 27 19:11:17 2020 -0300
16212: Upgrades react & react-dom to support hooks.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/package.json b/package.json
index b0d49b2e..9e2b0f51 100644
--- a/package.json
+++ b/package.json
@@ -35,11 +35,11 @@
"mem": "4.0.0",
"prop-types": "15.7.2",
"query-string": "6.9.0",
- "react": "16.5.2",
+ "react": "16.8.6",
"react-copy-to-clipboard": "5.0.1",
"react-dnd": "5.0.0",
"react-dnd-html5-backend": "5.0.1",
- "react-dom": "16.5.2",
+ "react-dom": "16.8.6",
"react-dropzone": "5.1.1",
"react-highlight-words": "0.14.0",
"react-redux": "5.0.7",
diff --git a/yarn.lock b/yarn.lock
index 41aaa359..4c382850 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8415,15 +8415,15 @@ react-dnd at 5.0.0:
recompose "^0.27.1"
shallowequal "^1.0.2"
-react-dom at 16.5.2:
- version "16.5.2"
- resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7"
- integrity sha512-RC8LDw8feuZOHVgzEf7f+cxBr/DnKdqp56VU0lAs1f4UfKc4cU8wU4fTq/mgnvynLQo8OtlPC19NUFh/zjZPuA==
+react-dom at 16.8.6:
+ version "16.8.6"
+ resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f"
+ integrity sha512-1nL7PIq9LTL3fthPqwkvr2zY7phIPjYrT0jp4HjyEQrEROnw4dG41VVwi/wfoCneoleqrNX7iAD+pXebJZwrwA==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
- schedule "^0.5.0"
+ scheduler "^0.13.6"
react-dropzone at 5.1.1:
version "5.1.1"
@@ -8608,15 +8608,15 @@ react-transition-group@^2.2.1:
prop-types "^15.6.2"
react-lifecycles-compat "^3.0.4"
-react at 16.5.2:
- version "16.5.2"
- resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
- integrity sha512-FDCSVd3DjVTmbEAjUNX6FgfAmQ+ypJfHUsqUJOYNCBUp1h8lqmtC+0mXJ+JjsWx4KAVTkk1vKd1hLQPvEviSuw==
+react at 16.8.6:
+ version "16.8.6"
+ resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe"
+ integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
- schedule "^0.5.0"
+ scheduler "^0.13.6"
read-pkg-up@^1.0.1:
version "1.0.1"
@@ -9213,11 +9213,12 @@ sax@^1.2.1, sax@^1.2.4, sax@~1.2.1:
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
-schedule@^0.5.0:
- version "0.5.0"
- resolved "https://registry.yarnpkg.com/schedule/-/schedule-0.5.0.tgz#c128fffa0b402488b08b55ae74bb9df55cc29cc8"
- integrity sha512-HUcJicG5Ou8xfR//c2rPT0lPIRR09vVvN81T9fqfVgBmhERUbDEQoYKjpBxbueJnCPpSu2ujXzOnRQt6x9o/jw==
+scheduler@^0.13.6:
+ version "0.13.6"
+ resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889"
+ integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ==
dependencies:
+ loose-envify "^1.1.0"
object-assign "^4.1.1"
scheduler@^0.17.0:
commit b0dfa5747fbfb69a55ed9104a0dbed784becfb0c
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Fri Mar 27 18:50:04 2020 -0300
16212: Loads PAM login feature from exported config.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/common/config.ts b/src/common/config.ts
index 0a13f4e1..f9fb9f6a 100644
--- a/src/common/config.ts
+++ b/src/common/config.ts
@@ -58,6 +58,7 @@ export interface ClusterConfigJSON {
};
Login: {
LoginCluster: string;
+ PAM: boolean;
};
Collections: {
ForwardSlashNameSubstitution: string;
@@ -187,6 +188,7 @@ export const mockClusterConfigJSON = (config: Partial<ClusterConfigJSON>): Clust
},
Login: {
LoginCluster: "",
+ PAM: false,
},
Collections: {
ForwardSlashNameSubstitution: "",
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list