【问题标题】:iOS Timeout for Incorrect PasscodeiOS 密码错误超时
【发布时间】:2016-04-28 12:26:32
【问题描述】:

在我正在开发的应用程序中,我让用户使用密码作为其 TouchID 的备份。显然,出于安全原因,此密码应具有某种形式的“超时”,类似于 iPhone 锁定屏幕。

实现这一目标的最佳方法是什么?

我最初的想法是保存用户上次不正确的尝试,并检查它是否比当前日期早 x 分钟。

我认为这在实践中可行,但将其与系统时钟绑定绝对不是最安全的方式。

对于此事的任何帮助将不胜感激。

【问题讨论】:

    标签: ios swift security


    【解决方案1】:

    我已经在几个应用程序中实现了这种形式。我通常做的是使用一个计时器,该计时器在用户与应用程序交互时开始(如果存在,也会取消前一个计时器)。当时间用完时,将运行 timeout 方法。
    像这样的:

    - (void)pressedButton:(UIButton *)button {
      // record button press
    
      [self scheduleInteractionTimer];
    }
    
    - (void)scheduleInteractionTimer {
      if (_timeoutTimer) {
        [_timeoutTimer invalidate];
      }
      _timeoutTimer = [NSTimer timerWithTimeInterval:timeoutTime target:self selector:@selector(timeoutTripped) userInfo:nil repeats:NO];
      _timeoutTimer.tolerance = 5.0; // optional
      [[NSRunLoop mainRunLoop] addTimer:_timeoutTimer forMode:NSRunLoopCommonModes];
    }
    
    - (void)timeoutTripped {
      // whatever should be done for a timeout...
    }
    

    您绝对可以将 -scheduleInteractionTimer 与不正确的响应或您想要的任何其他内容联系起来。

    编辑:我还建议在应用进入后台时关闭密码视图。

    干杯

    安东尼

    【讨论】:

      猜你喜欢
      • 2020-04-13
      • 2016-10-02
      • 1970-01-01
      • 2016-06-13
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多