Skip to content

Commit

Permalink
fix(jmxauth): remove references to client-side localstorage JMX crede…
Browse files Browse the repository at this point in the history
…ntial passthrough (#1241)
  • Loading branch information
andrewazores authored Apr 24, 2024
1 parent c2f01e0 commit 2e0357d
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 854 deletions.
13 changes: 5 additions & 8 deletions src/app/AppLayout/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onProps
filter((target) => !!target),
first(),
map((target: Target) => target.connectUrl),
mergeMap((connectUrl) => context.authCredentials.setCredential(connectUrl, username, password)),
mergeMap((connectUrl) =>
context.api.postCredentials(`target.connectUrl == "${connectUrl}"`, username, password),
),
)
.subscribe((ok) => {
setLoading(false);
Expand All @@ -53,7 +55,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onProps
}),
);
},
[addSubscription, context.authCredentials, targetObs, setLoading, onPropsSave],
[addSubscription, context.api, targetObs, setLoading, onPropsSave],
);

return (
Expand All @@ -70,12 +72,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onProps
<Link onClick={onDismiss} to="/security">
Security
</Link>{' '}
to add a credential matching multiple targets. Visit{' '}
<Link onClick={onDismiss} to="/settings">
Settings
</Link>{' '}
to confirm and configure whether these credentials will be held only for this browser session or stored
encrypted in the Cryostat backend.
to add a credential matching multiple targets.
</Text>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
import { OutlinedQuestionCircleIcon, SearchIcon } from '@patternfly/react-icons';
import { ExpandableRowContent, TableComposable, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { forkJoin } from 'rxjs';
import { SecurityCard } from '../types';
import { CreateCredentialModal } from './CreateCredentialModal';
Expand Down Expand Up @@ -179,7 +178,7 @@ const tableColumns: TableColumn[] = [

const tableTitle = 'Stored Credentials';

export const StoreCredentials = () => {
export const StoredCredentials = () => {
const context = React.useContext(ServiceContext);
const [state, dispatch] = React.useReducer(reducer, {
credentials: [] as StoredCredential[],
Expand Down Expand Up @@ -519,7 +518,7 @@ export const CheckBoxActions: React.FC<CheckBoxActionsProps> = ({
);
};

export const StoreCredentialsCard: SecurityCard = {
export const StoredCredentialsCard: SecurityCard = {
key: 'credentials',
title: (
<Text>
Expand All @@ -535,13 +534,9 @@ export const StoreCredentialsCard: SecurityCard = {
<TextContent>
<Text component={TextVariants.small}>
Credentials that Cryostat uses to connect to Cryostat agents or target JVMs over JMX are stored in encrypted
storage.
</Text>
<Text component={TextVariants.small}>
The locally-stored client credentials held by your browser session are not displayed here. See{' '}
<Link to="/settings?tab=advanced">Settings</Link> to configure locally-stored credentials.
storage managed by the Cryostat server.
</Text>
</TextContent>
),
content: StoreCredentials,
content: StoredCredentials,
};
4 changes: 2 additions & 2 deletions src/app/SecurityPanel/SecurityPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import { BreadcrumbPage } from '@app/BreadcrumbPage/BreadcrumbPage';
import { Card, CardBody, CardTitle, Text, TextVariants } from '@patternfly/react-core';
import * as React from 'react';
import { StoreCredentialsCard } from './Credentials/StoreCredentials';
import { StoredCredentialsCard } from './Credentials/StoredCredentials';
import { ImportCertificate } from './ImportCertificate';

export interface SecurityPanelProps {}

export const SecurityPanel: React.FC<SecurityPanelProps> = (_) => {
const securityCards = [ImportCertificate, StoreCredentialsCard].map((c) => ({
const securityCards = [ImportCertificate, StoredCredentialsCard].map((c) => ({
key: c.key,
title: c.title,
description: c.description,
Expand Down
112 changes: 0 additions & 112 deletions src/app/Settings/Config/CredentialsStorage.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/app/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { AutomatedAnalysis } from './Config/AutomatedAnalysis';
import { AutoRefresh } from './Config/AutoRefresh';
import { ChartCards } from './Config/ChartCards';
import { CredentialsStorage } from './Config/CredentialsStorage';
import { DatetimeControl } from './Config/DatetimeControl';
import { DeletionDialogControl } from './Config/DeletionDialogControl';
import { FeatureLevels } from './Config/FeatureLevels';
Expand All @@ -62,7 +61,6 @@ export const Settings: React.FC<SettingsProps> = (_) => {
NotificationControl,
AutomatedAnalysis,
ChartCards,
CredentialsStorage,
DeletionDialogControl,
WebSocketDebounce,
AutoRefresh,
Expand Down
55 changes: 0 additions & 55 deletions src/app/Shared/Services/AuthCredentials.service.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions src/app/Shared/Services/Services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
import * as React from 'react';
import { ApiService } from './Api.service';
import { AuthCredentials } from './AuthCredentials.service';
import { LoginService } from './Login.service';
import { NotificationChannel } from './NotificationChannel.service';
import { NotificationsInstance } from './Notifications.service';
Expand All @@ -28,7 +27,6 @@ export interface Services {
target: TargetService;
targets: TargetsService;
api: ApiService;
authCredentials: AuthCredentials;
notificationChannel: NotificationChannel;
reports: ReportService;
settings: SettingsService;
Expand All @@ -37,7 +35,6 @@ export interface Services {

const target = new TargetService();
const settings = new SettingsService();
const authCredentials = new AuthCredentials(() => api);
const login = new LoginService(settings);
const api = new ApiService(target, NotificationsInstance, login);
const notificationChannel = new NotificationChannel(NotificationsInstance, login);
Expand All @@ -48,7 +45,6 @@ const defaultServices: Services = {
target,
targets,
api,
authCredentials,
notificationChannel,
reports,
settings,
Expand Down
5 changes: 1 addition & 4 deletions src/app/Topology/Actions/CreateTarget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@

import openjdkSvg from '@app/assets/openjdk.svg';
import { BreadcrumbPage } from '@app/BreadcrumbPage/BreadcrumbPage';
import { Locations } from '@app/Settings/Config/CredentialsStorage';
import { LinearDotSpinner } from '@app/Shared/Components/LinearDotSpinner';
import { LoadingProps } from '@app/Shared/Components/types';
import { Target } from '@app/Shared/Services/api.types';
import { isHttpOk } from '@app/Shared/Services/api.utils';
import { ServiceContext } from '@app/Shared/Services/Services';
import '@app/Topology/styles/base.css';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { getFromLocalStorage } from '@app/utils/LocalStorage';
import { getAnnotation, portalRoot } from '@app/utils/utils';
import {
Accordion,
Expand Down Expand Up @@ -171,7 +169,6 @@ export const CreateTarget: React.FC<CreateTargetProps> = ({ prefilled }) => {
const handleSubmit = React.useCallback(() => {
setLoading(true);
// Get storage location
const locationKey = getFromLocalStorage('CREDENTIAL_LOCATION', Locations.BACKEND.key);
addSubscription(
context.api
.createTarget(
Expand All @@ -180,7 +177,7 @@ export const CreateTarget: React.FC<CreateTargetProps> = ({ prefilled }) => {
alias: alias.trim() || connectUrl,
},
credentials,
locationKey === Locations.BACKEND.key,
true,
)
.subscribe(({ status, body }) => {
setLoading(false);
Expand Down
Loading

0 comments on commit 2e0357d

Please sign in to comment.