Skip to content

Commit

Permalink
fix(ntlm): fixed password encryptiong
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherpickering committed Aug 21, 2023
1 parent 8b50648 commit 9c1b935
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/components/monitorForms/http.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function HttpForm({
<Input
type="text"
id="httpUrl"
value={data.httpUrl}
value={data.httpUrl || ''}
placeholder="https://google.com"
className="col-span-3"
onChange={(e) => setData({ ...data, httpUrl: e.target.value })}
Expand Down
13 changes: 9 additions & 4 deletions app/monitors/http.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export async function HttpCheck({

if (httpAuthentication === 'basic') {
basicAuthHeader = {
Authorization: 'Basic ' + encodeBase64(httpUsername, httpPassword),
Authorization:
'Basic ' + encodeBase64(httpUsername, decrypt(httpPassword)),
};
}

Expand Down Expand Up @@ -151,12 +152,16 @@ export async function HttpCheck({
try {
if (httpAuthentication === 'ntlm') {
options.httpsAgent.keepAlive = true;
let client = NtlmClient({

let credentials: NtlmCredentials = {
username: httpUsername || '',
password: httpPassword || '',
password: httpPassword ? decrypt(httpPassword) : '',
domain: httpDomain || '',
workstation: httpWorkstation ? httpWorkstation : undefined,
});
};

let client = NtlmClient(credentials);

res = await client(options);
} else {
res = await axios.request(options);
Expand Down
4 changes: 2 additions & 2 deletions app/notifications/notifier.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMonitor } from '~/models/monitor.server';
import { Monitor, getMonitor } from '~/models/monitor.server';
import type { Drive, DriveUsage } from '~/models/monitor.server';
import SMTP from './smtp';
import Telegram from './telegram';
Expand Down Expand Up @@ -29,7 +29,7 @@ export default async function Notifier({

if (monitor.type === 'windows' || monitor.type === 'ubuntu') {
// reboot notifier
await rebootNotifier({ monitor, oldMonitor });
if (oldMonitor) await rebootNotifier({ monitor, oldMonitor });

// drive notifications
monitor?.drives?.map(async (drive: Drive & { usage: DriveUsage[] }) => {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_auth.monitor.new/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export async function action({ request }: ActionArgs) {
httpBody: values.httpBody?.toString(),
httpAuthentication: values.httpAuthentication?.toString(),
httpUsername: values.httpUsername?.toString(),
httpPassword: values.httpPassword?.toString(),
httpPassword: encrypt(values.httpPassword?.toString()),
httpIgnoreSsl: !!values.httpIgnoreSsl,
httpBodyEncoding: values.httpBodyEncoding?.toString(),
httpUrl: values.httpUrl?.toString(),
Expand Down

0 comments on commit 9c1b935

Please sign in to comment.