Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionSettings } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const AwsV4Auth = ({ collection }) => {
Expand Down Expand Up @@ -143,7 +144,7 @@ const AwsV4Auth = ({ collection }) => {
onSave={handleSave}
onChange={(val) => handleSecretAccessKeyChange(val)}
collection={collection}
isSecret={true}
isSecret={shouldMaskValue(awsv4Auth.secretAccessKey)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="awsv4-secret-access-key" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionSettings } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const BasicAuth = ({ collection }) => {
Expand Down Expand Up @@ -67,7 +68,7 @@ const BasicAuth = ({ collection }) => {
onSave={handleSave}
onChange={(val) => handlePasswordChange(val)}
collection={collection}
isSecret={true}
isSecret={shouldMaskValue(basicAuth.password)}
Comment thread
albertasaftei marked this conversation as resolved.
Resolved
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="basic-password" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionSettings } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const BearerAuth = ({ collection }) => {
Expand Down Expand Up @@ -41,7 +42,7 @@ const BearerAuth = ({ collection }) => {
onSave={handleSave}
onChange={(val) => handleTokenChange(val)}
collection={collection}
isSecret={true}
isSecret={shouldMaskValue(bearerToken)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="bearer-token" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionSettings } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const DigestAuth = ({ collection }) => {
Expand Down Expand Up @@ -67,7 +68,7 @@ const DigestAuth = ({ collection }) => {
onSave={handleSave}
onChange={(val) => handlePasswordChange(val)}
collection={collection}
isSecret={true}
isSecret={shouldMaskValue(digestAuth.password)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="digest-password" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useDispatch } from 'react-redux';
import SensitiveFieldWarning from 'components/SensitiveFieldWarning';
import SingleLineEditor from 'components/SingleLineEditor';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField';
import { shouldMaskValue } from 'utils/auth';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions';
import { useTheme } from 'providers/Theme';
Expand Down Expand Up @@ -129,7 +130,7 @@ const EdgeGridAuth: React.FC<AkamaiEdgeGridAuthProps> = ({ collection }) => {
onSave={handleSave}
onChange={(val: string) => handleFieldChange(key, val)}
collection={collection}
isSecret={isSecret}
isSecret={isSecret && shouldMaskValue(fieldValue)}
isCompact
/>
{showWarning && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionSettings } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const NTLMAuth = ({ collection }) => {
Expand All @@ -28,7 +29,6 @@ const NTLMAuth = ({ collection }) => {
username: username || '',
password: ntlmAuth.password || '',
domain: ntlmAuth.domain || ''

}
})
);
Expand Down Expand Up @@ -84,7 +84,7 @@ const NTLMAuth = ({ collection }) => {
onSave={handleSave}
onChange={(val) => handlePasswordChange(val)}
collection={collection}
isSecret={true}
isSecret={shouldMaskValue(ntlmAuth.password)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="ntlm-password" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionSettings } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const WsseAuth = ({ collection }) => {
Expand Down Expand Up @@ -67,7 +68,7 @@ const WsseAuth = ({ collection }) => {
onSave={handleSave}
onChange={(val) => handlePasswordChange(val)}
collection={collection}
isSecret={true}
isSecret={shouldMaskValue(wsseAuth.password)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="wsse-password" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import path from 'utils/common/path';
import SensitiveFieldWarning from 'components/SensitiveFieldWarning/index';
import SingleLineEditor from 'components/SingleLineEditor/index';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField/index';
import { shouldMaskValue } from 'utils/auth';
import { useTheme } from 'styled-components';
import { useDispatch } from 'react-redux';
import { updateCollectionClientCertificates } from 'providers/ReduxStore/slices/collections';
Expand Down Expand Up @@ -366,7 +367,7 @@ const ClientCertSettings = ({ collection }) => {
theme={storedTheme}
onChange={(val) => formik.setFieldValue('passphrase', val)}
collection={collection}
isSecret={true}
isSecret={shouldMaskValue(formik.values.passphrase)}
/>
{showWarning && <SensitiveFieldWarning fieldName="basic-password" warningMessage={warningMessage} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collection
import StyledWrapper from './StyledWrapper';
import SensitiveFieldWarning from 'components/SensitiveFieldWarning';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField';
import { shouldMaskValue } from 'utils/auth';

const AwsV4Auth = ({ item, collection, updateAuth, request, save }) => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -157,7 +158,7 @@ const AwsV4Auth = ({ item, collection, updateAuth, request, save }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(awsv4Auth.secretAccessKey)}
isCompact
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateAuth } from 'providers/ReduxStore/slices/collections';
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const BasicAuth = ({ item, collection, updateAuth, request, save }) => {
Expand Down Expand Up @@ -77,7 +78,7 @@ const BasicAuth = ({ item, collection, updateAuth, request, save }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(basicAuth.password)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="basic-password" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateAuth } from 'providers/ReduxStore/slices/collections';
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const BearerAuth = ({ item, collection, updateAuth, request, save }) => {
Expand Down Expand Up @@ -49,7 +50,7 @@ const BearerAuth = ({ item, collection, updateAuth, request, save }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(bearerToken)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="bearer-token" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTheme } from 'providers/Theme';
import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const DigestAuth = ({ item, collection, updateAuth, request, save }) => {
Expand Down Expand Up @@ -76,7 +77,7 @@ const DigestAuth = ({ item, collection, updateAuth, request, save }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(digestAuth.password)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="digest-password" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useDispatch } from 'react-redux';
import SensitiveFieldWarning from 'components/SensitiveFieldWarning';
import SingleLineEditor from 'components/SingleLineEditor';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField';
import { shouldMaskValue } from 'utils/auth';
import { sendRequest } from 'providers/ReduxStore/slices/collections/actions';
import { useTheme } from 'providers/Theme';
import StyledWrapper from './StyledWrapper';
Expand Down Expand Up @@ -138,7 +139,7 @@ const EdgeGridAuth: React.FC<AkamaiEdgeGridAuthProps> = ({ item, collection, upd
onRun={handleRun}
collection={collection}
item={item}
isSecret={isSecret}
isSecret={isSecret && shouldMaskValue(fieldValue)}
isCompact
/>
{showWarning && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateAuth } from 'providers/ReduxStore/slices/collections';
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const NTLMAuth = ({ item, collection, request, save, updateAuth }) => {
Expand Down Expand Up @@ -94,7 +95,7 @@ const NTLMAuth = ({ item, collection, request, save, updateAuth }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(ntlmAuth.password)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="ntlm-password" warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SensitiveFieldWarning from 'components/SensitiveFieldWarning';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField';
import toast from 'react-hot-toast';
import { sendRequest, browseFiles } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const signatureMethodLabels = {
Expand Down Expand Up @@ -148,7 +149,7 @@ const OAuth1 = ({ item = {}, collection, request, save, updateAuth }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(oauth1.consumerSecret)}
isCompact
/>
{consumerSecretSensitive.showWarning && <SensitiveFieldWarning fieldName="oauth1-consumer-secret" warningMessage={consumerSecretSensitive.warningMessage} />}
Expand Down Expand Up @@ -183,7 +184,7 @@ const OAuth1 = ({ item = {}, collection, request, save, updateAuth }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(oauth1.accessTokenSecret)}
isCompact
/>
{tokenSecretSensitive.showWarning && <SensitiveFieldWarning fieldName="oauth1-token-secret" warningMessage={tokenSecretSensitive.warningMessage} />}
Expand Down Expand Up @@ -247,7 +248,7 @@ const OAuth1 = ({ item = {}, collection, request, save, updateAuth }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(privateKeyValue)}
allowNewlines={true}
/>
{privateKeySensitive.showWarning && <SensitiveFieldWarning fieldName="oauth1-private-key" warningMessage={privateKeySensitive.warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField';
import { shouldMaskValue } from 'utils/auth';
import get from 'lodash/get';
import { useTheme } from 'providers/Theme';
import { useDispatch, useSelector } from 'react-redux';
Expand Down Expand Up @@ -212,7 +213,7 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
onRun={handleRun}
collection={collection}
item={item}
isSecret={isSecret}
isSecret={isSecret && shouldMaskValue(value)}
isCompact
/>
{isSecret && showWarning && <SensitiveFieldWarning fieldName={key} warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField';
import { shouldMaskValue } from 'utils/auth';
import get from 'lodash/get';
import { useTheme } from 'providers/Theme';
import { useDispatch } from 'react-redux';
Expand Down Expand Up @@ -97,7 +98,7 @@ const OAuth2ClientCredentials = ({ save, item = {}, request, handleRun, updateAu
onRun={handleRun}
collection={collection}
item={item}
isSecret={isSecret}
isSecret={isSecret && shouldMaskValue(value)}
isCompact
/>
{isSecret && showWarning && <SensitiveFieldWarning fieldName={key} warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField';
import { shouldMaskValue } from 'utils/auth';
import get from 'lodash/get';
import { useTheme } from 'providers/Theme';
import { useDispatch } from 'react-redux';
Expand Down Expand Up @@ -101,7 +102,7 @@ const OAuth2PasswordCredentials = ({ save, item = {}, request, handleRun, update
onRun={handleRun}
collection={collection}
item={item}
isSecret={isSecret}
isSecret={isSecret && shouldMaskValue(value)}
isCompact
/>
{isSecret && showWarning && <SensitiveFieldWarning fieldName={key} warningMessage={warningMessage} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateAuth } from 'providers/ReduxStore/slices/collections';
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
import { shouldMaskValue } from 'utils/auth';
import StyledWrapper from './StyledWrapper';

const WsseAuth = ({ item, collection, updateAuth, request, save }) => {
Expand Down Expand Up @@ -77,7 +78,7 @@ const WsseAuth = ({ item, collection, updateAuth, request, save }) => {
onRun={handleRun}
collection={collection}
item={item}
isSecret={true}
isSecret={shouldMaskValue(wsseAuth.password)}
isCompact
/>
{showWarning && <SensitiveFieldWarning fieldName="wsse-password" warningMessage={warningMessage} />}
Expand Down
12 changes: 12 additions & 0 deletions packages/bruno-app/src/utils/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,15 @@ export const hasEffectiveAuth = (collection, item, supportedModes) => {
if (supportedModes && !supportedModes.includes(mode)) return false;
return true;
};

/**
* Determines whether a value should be masked as a secret in the editor.
* Returns false when the value contains a variable reference (e.g. `{{token}}`),
* so the reference text stays visible and autocomplete works normally.
* Returns true for empty/plain-text values to keep isSecret stable and avoid
* visual flashing when the user starts typing.
*/
export const shouldMaskValue = (value) => {
if (!value || typeof value !== 'string') return true;
return !value.startsWith('{{');
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
7 changes: 2 additions & 5 deletions packages/bruno-app/src/utils/common/masked-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,8 @@ export class MaskedEditor {
handleInputRead() {
if (!this.enabled || this.isProcessing) return;

// Debounce masking to prevent excessive updates
clearTimeout(this.maskTimeout);
this.maskTimeout = setTimeout(() => {
this.update();
}, 10);
// Apply masking synchronously to prevent characters from briefly appearing unmasked
this.update();
}

/**
Expand Down