Open Daxcor69 opened 9 months ago
Ok with the help of chatGPT here is what I got working. This might help someone else
const webdav = require("webdav-server").v2;
class SimpleUserManager extends webdav.SimpleUserManager {
async getUserByNamePassword(name, password, callback) {
let user = await User.findOne({ username: name }).select("+password");
if (!user) {
callback(new Error("Bad Authentication"));
} else {
if (await user.matchPassword(password)) {
callback(null, this.addUser(user.name, user.password, false));
} else {
callback(new Error("Bad Authentication"));
}
}
}
}
const userManager = new SimpleUserManager();
// Create a new server instance
const server = new webdav.WebDAVServer({
// HTTP Basic authentication
httpAuthentication: new webdav.HTTPBasicAuthentication(userManager, "Default realm"),
rootFileSystem: new webdav.PhysicalFileSystem("/tmp/"),
});
// Start the server
server.start((s) => console.log("Ready on port", s.address().port));
I am running into an issue, that windows 11, is totally bypassing the authentication and allows full access with out credentials. Any idea why?
Adding requireAuthentification: true, has stopped the windows file explorer from having access, but now it wont grant access with the right credentials presented. I tired strictmode on and off. Any suggestions?
Hi,
I would try using a privilege manager that allows access only to users that belongs to a directory. This is the way I manage user access rights RO, RW to my directories. privilege manager can also manage disk space quota.
To acheive this I do :
Hope this helps !
Cheers
N.
I am looking to use mongo db as a authentication source for the server. I know nothing about TS and using classes and constructors. I am trying to understand the examples given but it just doesn't make any sense.
here is what Understand so far
When the sever starts, it adds the values for this user to some sort of memory table. Then when the requests comes it is compared and go or no go.
What I am looking for is the ability to get the incoming Basic auth values and look up my mongo table instead. I just can't figure out how to grab the values on connection, or does the server have to preload all the values ahead of any connection?
I have goggled around looking for some examples, if you have anything you can share would be most appreciative. Thanks,