From 02ddcb526c74b5e10f1145628bbbb64f6c452a5e Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sat, 17 May 2025 09:33:52 +0000 Subject: [PATCH] allowed.pm: noCheckFor Attribute (Forum #141561) git-svn-id: https://svn.fhem.de/fhem/trunk@29970 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/01_FHEMWEB.pm | 3 ++ fhem/FHEM/96_allowed.pm | 115 +++++++++++++++++++++++++++------------- 2 files changed, 80 insertions(+), 38 deletions(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 298827773..9bce77d20 100644 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -511,6 +511,7 @@ FW_Read($$) ############################# # AUTH + $FW_httpheader{_Path} = $arg; if(!defined($FW_chash->{Authenticated})) { my $ret = Authenticate($FW_chash, \%FW_httpheader); if($ret == 0) { @@ -523,6 +524,8 @@ FW_Read($$) $FW_headerlines .= $ah if($ah); delete $FW_chash->{".httpAuthHeader"}; + } elsif($ret == 3) { # OK for this URL + } else { my $ah = $FW_chash->{".httpAuthHeader"}; TcpServer_WriteBlocking($hash, diff --git a/fhem/FHEM/96_allowed.pm b/fhem/FHEM/96_allowed.pm index 206235e5c..5df954c57 100644 --- a/fhem/FHEM/96_allowed.pm +++ b/fhem/FHEM/96_allowed.pm @@ -4,7 +4,6 @@ package main; use strict; use warnings; -use vars qw(@FW_httpheader); # HTTP header, line by line use MIME::Base64; my $allowed_haveSha; @@ -34,6 +33,7 @@ allowed_Initialize($) disable:1,0 disabledForIntervals globalpassword + noCheckFor password reportAuthAttempts validFor @@ -130,7 +130,11 @@ allowed_Authorize($$$$;$) } ##################################### -# Return 0 for authentication not needed, 1 for auth-ok, 2 for wrong password +# Return +# - 0 for authentication not needed +# - 1 for auth-ok +# - 2 for wrong username/password +# - 3 authentication not needed this time (FHEMWEB special) sub allowed_Authenticate($$$$) { @@ -161,6 +165,9 @@ allowed_Authenticate($$$$) return &$doReturn(0) if(!$basicAuth); return &$doReturn(2) if(!$param); + my $exc = AttrVal($aName, "noCheckFor", undef); #141561 + return 3 if($exc && $param->{_Path} =~ m/$exc/); + my $FW_httpheader = $param; my $secret = $FW_httpheader->{Authorization}; $secret =~ s/^Basic //i if($secret); @@ -406,12 +413,12 @@ EOF =item summary_DE authorisiert Befehlsausführung basierend auf dem Frontend =begin html - +

allowed