Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cred): credential test table #920

Merged
merged 15 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion locales/en/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
"TITLE": "Session (Browser Memory)"
},
"DESCRIPTION": "When you attempt to connect to a target application which requires authentication, you will see a prompt for credentials to present to the application and complete the connection. You can choose where to persist these credentials. Any credentials added through the <0>Security</0> panel will always be stored in Cryostat backend encrypted storage.",
"TITLE": "JMX Credentials Storage"
"TITLE": "Credentials Storage"
},
"DATETIME_CONTROL": {
"ARIA_LABELS": {
Expand Down
4 changes: 2 additions & 2 deletions src/app/AppLayout/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onProps
filter((target) => target !== NO_TARGET),
first(),
map((target) => target.connectUrl),
mergeMap((connectUrl) => context.jmxCredentials.setCredential(connectUrl, username, password))
mergeMap((connectUrl) => context.authCredentials.setCredential(connectUrl, username, password))
)
.subscribe((ok) => {
setLoading(false);
Expand All @@ -76,7 +76,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onProps
})
);
},
[addSubscription, context.jmxCredentials, context.target, setLoading, onPropsSave]
[addSubscription, context.authCredentials, context.target, setLoading, onPropsSave]
);

return (
Expand Down
58 changes: 44 additions & 14 deletions src/app/AppLayout/CredentialAuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,31 @@ import { LoadingPropsType } from '@app/Shared/ProgressIndicator';
import { ActionGroup, Button, Form, FormGroup, TextInput } from '@patternfly/react-core';
import * as React from 'react';

export interface AuthCredential {
username: string;
password: string;
}

export interface CredentialAuthFormProps {
onDismiss: () => void;
onSave: (username: string, password: string) => void;
focus?: boolean;
loading?: boolean;
isDisabled?: boolean;
children?: React.ReactNode;
onCredentialChange?: (credential: AuthCredential) => void;
}

export const CredentialAuthForm: React.FC<CredentialAuthFormProps> = ({ onDismiss, onSave, ...props }) => {
export const CredentialAuthForm: React.FC<CredentialAuthFormProps> = ({
onDismiss,
onSave,
onCredentialChange,
loading,
isDisabled,
focus,
children,
...props
}) => {
const [username, setUsername] = React.useState('');
const [password, setPassword] = React.useState('');

Expand All @@ -73,35 +89,49 @@ export const CredentialAuthForm: React.FC<CredentialAuthFormProps> = ({ onDismis
() =>
({
spinnerAriaValueText: 'Saving',
spinnerAriaLabel: 'saving-jmx-credentials',
isLoading: props.loading,
spinnerAriaLabel: 'saving-credentials',
isLoading: loading,
} as LoadingPropsType),
[props.loading]
[loading]
);

return (
<Form>
{props.children}
<Form {...props}>
{children}
<FormGroup isRequired label="Username" fieldId="username">
<TextInput
value={username}
isDisabled={props.loading}
isDisabled={isDisabled || loading}
isRequired
type="text"
id="username"
onChange={setUsername}
onChange={(v) => {
setUsername(v);
onCredentialChange &&
onCredentialChange({
username: v,
password: password,
});
}}
onKeyUp={handleKeyUp}
autoFocus={props.focus}
autoFocus={focus}
/>
</FormGroup>
<FormGroup isRequired label="Password" fieldId="password">
<TextInput
value={password}
isDisabled={props.loading}
isDisabled={isDisabled || loading}
isRequired
type="password"
id="password"
onChange={setPassword}
onChange={(v) => {
setPassword(v);
onCredentialChange &&
onCredentialChange({
username: username,
password: v,
});
}}
onKeyUp={handleKeyUp}
/>
</FormGroup>
Expand All @@ -110,11 +140,11 @@ export const CredentialAuthForm: React.FC<CredentialAuthFormProps> = ({ onDismis
variant="primary"
onClick={handleSave}
{...saveButtonLoadingProps}
isDisabled={props.loading || username === '' || password === ''}
isDisabled={isDisabled || loading || username === '' || password === ''}
>
{props.loading ? 'Saving' : 'Save'}
{loading ? 'Saving' : 'Save'}
</Button>
<Button variant="secondary" onClick={handleDismiss} isDisabled={props.loading}>
<Button variant="secondary" onClick={handleDismiss} isDisabled={isDisabled || loading}>
Cancel
</Button>
</ActionGroup>
Expand Down
4 changes: 1 addition & 3 deletions src/app/Rules/CreateRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,7 @@ const CreateRuleForm: React.FC<CreateRuleFormProps> = ({ ...props }) => {
? `Warning: Match expression matches no targets.`
: `
Enter a match expression. This is a Java-like code snippet that is evaluated against each target
application to determine whether the rule should be applied. Select a target from the dropdown
on the right to view the context object available within the match expression context and test
if the expression matches.`
application to determine whether the rule should be applied.`
}
helperTextInvalid="Invalid Match Expression."
validated={matchExpressionValid}
Expand Down
Loading