Skip to content

Commit

Permalink
ntlm auth
Browse files Browse the repository at this point in the history
  • Loading branch information
tlaloc911 committed Oct 21, 2024
1 parent ac67c4c commit 07df644
Show file tree
Hide file tree
Showing 25 changed files with 488 additions and 11 deletions.
43 changes: 42 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
"prepare": "husky install"
},
"overrides": {
"rollup":"3.29.5"
"rollup": "3.29.5"
},
"dependencies": {
"axios-ntlm": "^1.4.2",
"json-bigint": "^1.0.0",
"lossless-json": "^4.0.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ const AuthMode = ({ collection }) => {
>
Digest Auth
</div>
<div
className="dropdown-item"
onClick={() => {
dropdownTippyRef.current.hide();
onModeChange('ntlm');
}}
>
NTLM Auth
</div>
<div
className="dropdown-item"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from 'styled-components';

const Wrapper = styled.div`
label {
font-size: 0.8125rem;
}
.single-line-editor-wrapper {
max-width: 400px;
padding: 0.15rem 0.4rem;
border-radius: 3px;
border: solid 1px ${(props) => props.theme.input.border};
background-color: ${(props) => props.theme.input.bg};
}
`;

export default Wrapper;
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React from 'react';
import get from 'lodash/get';
import { useTheme } from 'providers/Theme';
import { useDispatch } from 'react-redux';
import SingleLineEditor from 'components/SingleLineEditor';
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions';
import StyledWrapper from './StyledWrapper';





const NTLMAuth = ({ collection }) => {


const dispatch = useDispatch();
const { storedTheme } = useTheme();

const ntlmAuth = get(collection, 'root.request.auth.ntlm', {});

const handleSave = () => dispatch(saveCollectionRoot(collection.uid));


const handleUsernameChange = (username) => {
dispatch(
updateCollectionAuth({
mode: 'ntlm',
collectionUid: collection.uid,
content: {
username: username,
password: ntlmAuth.password,
domain: ntlmAuth.domain

}
})
);
};

const handlePasswordChange = (password) => {
dispatch(
updateCollectionAuth({
mode: 'ntlm',
collectionUid: collection.uid,
content: {
username: ntlmAuth.username,
password: password,
domain: ntlmAuth.domain
}
})
);
};

const handleDomainChange = (domain) => {
dispatch(
updateCollectionAuth({
mode: 'ntlm',
collectionUid: collection.uid,
content: {
username: ntlmAuth.username,
password: ntlmAuth.password,
domain: domain
}
})
);
};




return (
<StyledWrapper className="mt-2 w-full">
<label className="block font-medium mb-2">Username</label>
<div className="single-line-editor-wrapper mb-2">
<SingleLineEditor
value={ntlmAuth.username || ''}
theme={storedTheme}
onSave={handleSave}
onChange={(val) => handleUsernameChange(val)}
collection={collection}
/>
</div>

<label className="block font-medium mb-2">Password</label>
<div className="single-line-editor-wrapper">
<SingleLineEditor
value={ntlmAuth.password || ''}
theme={storedTheme}
onSave={handleSave}
onChange={(val) => handlePasswordChange(val)}
collection={collection}
isSecret={true}
/>
</div>

<label className="block font-medium mb-2">Domain</label>
<div className="single-line-editor-wrapper">
<SingleLineEditor
value={ntlmAuth.domain || ''}
theme={storedTheme}
onSave={handleSave}
onChange={(val) => handleDomainChange(val)}
collection={collection}
/>
</div>
</StyledWrapper>
);
};

export default NTLMAuth;
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import ApiKeyAuth from './ApiKeyAuth/';
import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions';
import StyledWrapper from './StyledWrapper';
import OAuth2 from './OAuth2';
import NTLMAuth from './NTLMAuth';


const Auth = ({ collection }) => {
const authMode = get(collection, 'root.request.auth.mode');
Expand All @@ -32,6 +34,9 @@ const Auth = ({ collection }) => {
case 'digest': {
return <DigestAuth collection={collection} />;
}
case 'ntlm': {
return <NTLMAuth collection={collection} />;
}
case 'oauth2': {
return <OAuth2 collection={collection} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ const AuthMode = ({ item, collection }) => {
>
Digest Auth
</div>
<div
className="dropdown-item"
onClick={() => {
dropdownTippyRef?.current?.hide();
onModeChange('ntlm');
}}
>
NTLM Auth
</div>
<div
className="dropdown-item"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from 'styled-components';

const Wrapper = styled.div`
label {
font-size: 0.8125rem;
}
.single-line-editor-wrapper {
max-width: 400px;
padding: 0.15rem 0.4rem;
border-radius: 3px;
border: solid 1px ${(props) => props.theme.input.border};
background-color: ${(props) => props.theme.input.bg};
}
`;

export default Wrapper;
Loading

0 comments on commit 07df644

Please sign in to comment.