mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-13 00:02:30 +10:00
Minimum viable NTLM auth implementation
Added env variable "VITE_NTLM_AUTH", if true, login page will attempt NTLM auth challenge instead of showing login page. If challenge is successful and an authenticate message is received, it will check for the existence of the user using the provided mail attribute, and create an account with a random, complex password, and then authenticate as the user.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { login, setupWorkspace } from "@/features/auth/services/auth-service";
|
||||
import { login, ntlmLogin, setupWorkspace } from "@/features/auth/services/auth-service";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAtom } from "jotai";
|
||||
import { authTokensAtom } from "@/features/auth/atoms/auth-tokens-atom";
|
||||
@ -38,6 +38,25 @@ export default function useAuth() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleNtlmSignIn = async () => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const res = await ntlmLogin();
|
||||
setIsLoading(false);
|
||||
setAuthToken(res.tokens);
|
||||
|
||||
navigate(APP_ROUTE.HOME);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
setIsLoading(false);
|
||||
notifications.show({
|
||||
message: err.response?.data.message,
|
||||
color: "red",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleInvitationSignUp = async (data: IAcceptInvite) => {
|
||||
setIsLoading(true);
|
||||
|
||||
@ -107,6 +126,7 @@ export default function useAuth() {
|
||||
|
||||
return {
|
||||
signIn: handleSignIn,
|
||||
ntlmSignIn: handleNtlmSignIn,
|
||||
invitationSignup: handleInvitationSignUp,
|
||||
setupWorkspace: handleSetupWorkspace,
|
||||
isAuthenticated: handleIsAuthenticated,
|
||||
|
||||
Reference in New Issue
Block a user