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 .= ""; $ret .= ""; @@ -177,13 +186,6 @@ sub GoogleAuth_Detail($@) { return $ret; } -sub GoogleAuth_Summary($$$$) { - my ($FW_wname, $name, $room, $pageHash) = @_; - my $qr_url = _ga_make_url($name); - my $secret_base32 = getKeyValue("googleAuth$name"); # read from fhem keystore - return unless defined($qr_url); - return ""; -} # helper functions sub _ga_make_url($) { @@ -288,7 +290,8 @@ sub gAuth($$) {
@@ -309,6 +312,10 @@ sub gAuth($$) {
  • ga_qrSize - select image size of qr code
  • ga_showKey - show key for manual use if set to 1
  • ga_showLink - show link to qr code if set to 1
  • +
  • ga_showQR - show qr code if set to 1
  • +
  • ga_strictCheck
    +      AttrVal = 1 : check given token against one token
    +      AttrVal = 0 : check given token against three tokens(default)


  • <\/a>
    "; + $ret .= "<\/a>" + if AttrVal($name,'ga_showQR',1); + $ret .= "
     Link to QR code<\/a><\/td>" if AttrVal($name,'ga_showLink',0); $ret .= "