diff --git a/FHEM/98_GoogleAuth.pm b/FHEM/98_GoogleAuth.pm index 892d8d7af..a461608c4 100644 --- a/FHEM/98_GoogleAuth.pm +++ b/FHEM/98_GoogleAuth.pm @@ -67,6 +67,9 @@ # fixed: problem on iOS if label contains spaces # added: issuer=FHEM in qr-code # +# 2017-01-16 - added: attributes ga_showQR, ga_strictCheck +# removed: FW_summaryFn (not really useful) +# =cut package main; @@ -87,13 +90,11 @@ sub GoogleAuth_Initialize($) { $hash->{SetFn} = "GoogleAuth_Set"; $hash->{GetFn} = "GoogleAuth_Get"; $hash->{FW_detailFn} = "GoogleAuth_Detail"; - $hash->{FW_summaryFn} = "GoogleAuth_Detail"; -# $hash->{AttrFn} = "GoogleAuth_Attr"; $hash->{AttrList} = "ga_labelName ". "ga_qrSize:100x100,200x200,300x300,400x400 ". - "ga_showKey:0,1 ". - "ga_showLink:0,1 ". + "ga_showKey:0,1 ga_showLink:0,1 ga_showQR:1,0 ". + "ga_strictCheck:0,1 ". "$readingFnAttributes"; } @@ -150,7 +151,12 @@ sub GoogleAuth_Get($$@) { Log3($hash,5,"googleAuth $name: secret_bytes=$secret_base32"); my $oath = Authen::OATH->new; - my @possible = map { _ga_make_token_6($oath->totp($secret_base32, $_)) } time-30, time, time+30; + my @possible; + if (AttrVal($name,'ga_strictCheck',0) == 1) { + @possible = _ga_make_token_6($oath->totp($secret_base32)); + } else { + @possible = map { _ga_make_token_6($oath->totp($secret_base32, $_)) } time-30, time, time+30; + } Log3($hash,4,"googleAuth $name: possible: ".join ' ',@possible); my $result = (grep /^$given_token$/, @possible) ? 1 : -1; @@ -167,7 +173,10 @@ sub GoogleAuth_Detail($@) { my $secret_base32 = getKeyValue("googleAuth$name"); # read from fhem keystore return unless defined($qr_url); my $ret = "
";
+ $ret .= " | ";
$ret .= "Link to QR code<\/a><\/td>" if AttrVal($name,'ga_showLink',0); $ret .= " |