Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Auth plugin improvements #48

Closed
wants to merge 2 commits into from

2 participants

@zannalov

While attempting to use the auth plugin at the same time as the browser plugin (and attempting to set up a digest file), came across a couple problems. It looks like no other plugins are using the PRIO_HIGH option, so that change shouldn't hurt anything, and ignoring empty lines in a password file definitely won't hurt anything.

zannalov added some commits
@zannalov zannalov Set auth plugin to have a high priority.
When used in conjunction with the browser plugin, the browser plugin
would reply before auth got a chance to process, and thus no auth
would ever be applied and the directory would be immediately
browseable. Setting the priority on the listener guarantees auth gets
a higher priority than browser (which uses normal priority).
112ac98
@zannalov zannalov Ignore empty lines (including one at end of file)
Many text editors will add a newline at the end of the file without asking the user.
cf353ae
@mikedeboer mikedeboer commented on the diff
lib/DAV/plugins/auth/file.js
@@ -43,6 +43,9 @@ function jsDAV_Auth_Backend_File(filename) {
return cbloadfile(err);
data.split("\n").forEach(function(line) {
+ if( '' == line ) /* ignore empty lines (including one at end of file) */
@mikedeboer Owner

wouldn't if (/^[\s\t\r\n]+$/.test(line)) be more accurate as to catching all types of empty lines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mikedeboer
Owner

I just re-implemented your fixes to also get rid of the peculiar way I implemented loading the contents of the .htpasswd file.

See ajaxorg/jsDAV#27

@zannalov
@mikedeboer
Owner

since I just merged ajaxorg/jsDAV#27 I can close this one. Thanks again!

@mikedeboer mikedeboer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 19, 2012
  1. @zannalov

    Set auth plugin to have a high priority.

    zannalov authored
    When used in conjunction with the browser plugin, the browser plugin
    would reply before auth got a chance to process, and thus no auth
    would ever be applied and the directory would be immediately
    browseable. Setting the priority on the listener guarantees auth gets
    a higher priority than browser (which uses normal priority).
  2. @zannalov

    Ignore empty lines (including one at end of file)

    zannalov authored
    Many text editors will add a newline at the end of the file without asking the user.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +2 −1  lib/DAV/plugins/auth.js
  2. +3 −0  lib/DAV/plugins/auth/file.js
View
3  lib/DAV/plugins/auth.js
@@ -8,6 +8,7 @@
"use strict";
var jsDAV_ServerPlugin = require("./../plugin").jsDAV_ServerPlugin;
+var jsDAV_Util_EventEmitter_PRIO_HIGH = require("./../util").EventEmitter.PRIO_HIGH;
/**
* This plugin provides Authentication for a WebDAV server.
@@ -41,7 +42,7 @@ function jsDAV_Auth_Plugin(handler) {
this.realm = null;
this.initialize = function() {
- this.handler.addEventListener("beforeMethod", this.beforeMethod.bind(this));
+ this.handler.addEventListener("beforeMethod", this.beforeMethod.bind(this), jsDAV_Util_EventEmitter_PRIO_HIGH);
};
/**
View
3  lib/DAV/plugins/auth/file.js
@@ -43,6 +43,9 @@ function jsDAV_Auth_Backend_File(filename) {
return cbloadfile(err);
data.split("\n").forEach(function(line) {
+ if( '' == line ) /* ignore empty lines (including one at end of file) */
@mikedeboer Owner

wouldn't if (/^[\s\t\r\n]+$/.test(line)) be more accurate as to catching all types of empty lines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ cbloadfile();
+
var parts = line.split(":");
if (line.length !== 3)
cbloadfile(new Exc.jsDAV_Exception("Malformed htdigest file. Every line should contain 2 colons"));
Something went wrong with that request. Please try again.