question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lighttpd htpasswd authentification

See original GitHub issue

Hi Jens,

vorab vielen Dank für deine tolle Arbeit und Unterstützung im ganzen Projekt. So, nun aber zum “fehlerhaften” Part. Ich nutze aktuell (noch bzw. wieder) das Release “RaspberryMatic 2.31.25.20180225”, bei welchem alles so funktioniert wie es soll.

Seit dem Update auf “RaspberryMatic 2.31.25.20180324” oder auch “RaspberryMatic 2.31.25.20180428” stimmt irgend was nicht mehr mit lighttpd und zwar konkret mit dem Authentifizierungsmodul über htpasswd.

Über den Aufruf einer geschützen Seite (z.B. XML API) gehen leider wirklich willkürlich Benutzer und Passwörter oder eben auch nicht beim Login. Ich habe diverse Kombinationen ausgetestet, leider kein logisches Muster. Ebenso wird in den Logs nichts gespeichert, nur das eben die Kobination zwischen Benutzer und Passwort nicht stimmen. Es wurden zudem die User + PW neu generiert, sowie die vorhandenen getestet… keine Chance ein Muster zu erkennen.

Beispiel: User: test Passwort: test –> geht

Beispiel 2: User: test2 Passwort: test –> geht nicht

/etc/lighttpd/conf.d/auth.conf:

auth.backend = "htpasswd" 
auth.backend.htpasswd.userfile = "/etc/lighttpd/.lighttpdpassword"
auth.require = (
        "/config/xmlapi" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
        "/addons/xmlapi" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
	"/config/email" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
        "/addons/email" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),	
	"/config/cuxd" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
        "/addons/cuxd" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        )
)

/etc/lighttpd/.lighttpdpassword:

test:$apr1$bUJZ8ZB0$xxLP2bXQbocyASNUd3htD0
test2:$apr1$bUJZ8ZB0$xxLP2bXQbocyASNUd3htD0

/etc/lighttpd/lighttpd.conf: -> nur letzte Zeile hinzugefügt

include "/etc/lighttpd/conf.d/auth.conf"

/etc/lighttpd/lighttpd_ssl.conf: -> nur letzte Zeile hinzugefügt

include "/etc/lighttpd/conf.d/auth.conf"

Ggf. kannst du mal schauen was sich zwischen deinen Releases am lighttpd und auth modul selbst geändert hat. Kann gerne sonst noch Feedback geben, falls du Infos für einen PoC brauchst.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
jens-mauscommented, Aug 17, 2018

@pfetzing Deine Vermutung war richtig, es liegt an der lighttpd 1.4.48 version die anscheinend einen Bug in der base64 dekodierungsfunktion hat. Habe nun für den nächsten Release auf die 1.4.50 version geupdatet und hoffe das damit das Problem beseitigt sein wird.

1reaction
fl0wdecommented, Aug 17, 2018

Gerne, dann hier mein kleiner PoC. Habe alle Pfade angepasst, d.h. keine Schreibrechte mehr mit extra mount nötig.

/etc/config/lighttpd/auth.conf

auth.backend = "htpasswd" 
auth.backend.htpasswd.userfile = "/etc/config/lighttpd/.lighttpdpassword"
auth.require = (
        "/config/xmlapi" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
        "/addons/xmlapi" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
		

		"/config/email" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
        "/addons/email" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
		
		
		"/config/cuxd" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        ),
        "/addons/cuxd" =>
        (
                "method" => "basic",
                "realm" => "api",
                "require" => "valid-user"
        )
)

/etc/config/lighttpd/.lighttpdpassword (pro Zeile ein User:Passwort)

test:$apr1$e3VyFbci$fZYDOEKytnbJO2pWsI7oe/
test2:$apr1$e3VyFbci$fZYDOEKytnbJO2pWsI7oe/
test3:$apr1$e3VyFbci$fZYDOEKytnbJO2pWsI7oe/

-> Passwort ist immer: test -> Kannst du auch selbst in der Shell erstellen mit: htpasswd -n test

  1. Restart von httplight: /etc/init.d/S50lighttpd restart
  2. curl Aufruf mit user: curl -k http://test:test@10.24.1.30/addons/xmlapi/info.html -> 200 - OK
  3. curl Aufruf mit user2: curl -k http://test2:test@10.24.1.30/addons/xmlapi/info.html -> 401 - Unauthorized
  4. curl Aufruf mit user3: curl -k http://test3:test@10.24.1.30/addons/xmlapi/info.html -> 401 - Unauthorized

Fazit: Die 3 User sind nur exemplarisch, d.h. manche User gehen und manche nicht. Ggf. regex match oder so… und dann falsches Passwort herangezogen. Bin gespannt was dein Debug bringt. Danke 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module mod_auth - Using Authentication - lighty labs - Lighttpd
htpasswd (mod_authn_file)¶ ... A file which contains username and the crypt()'ed password separated by a colon. Each entry is terminated by a single...
Read more >
Lighttpd setup a password protected directory (directories)
If you require authentication on certain directories using the Lighttpd web server, you can use Lighttpd's mod_auth module.
Read more >
Basic authentication configurations for Lighttpd under Ubuntu
htpasswd <Username> #Replace <Username>, you will be prompted to enter the password. # Make sure that "mod_auth" is loaded in "server.modules". nano / ......
Read more >
Password-protect A lighttpd Web Server on a Raspberry Pi ...
Create A Password File. This file can go anywhere, but for simplicity in this walkthrough, we'll store it in /etc/lighttpd/.htpasswd ...
Read more >
Lighttpd: htpasswd protection - htaccess
Provided you've created the .htpasswd file correctly, the only problem I see with your config segment is the auth.require path - this should ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found