Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #1359: Updating U2F/WebAuthn modals to include site host (#1392)
Browse files Browse the repository at this point in the history
  • Loading branch information
jumde authored and jhreis committed Aug 20, 2019
1 parent c2f744f commit 4546189
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
"images" : [
{
"idiom" : "universal",
"filename" : "[email protected]"
"filename" : "Artboard.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions Client/Frontend/Popup/AlertPopupView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AlertPopupView: PopupView {
fileprivate let kPadding: CGFloat = 20.0

init(imageView: UIView?, title: String, message: String, inputType: UIKeyboardType? = nil,
secureInput: Bool = false, inputPlaceholder: String? = nil) {
secureInput: Bool = false, inputPlaceholder: String? = nil, titleWeight: UIFont.Weight = UIFont.Weight.bold, titleSize: CGFloat = 24) {
super.init(frame: CGRect.zero)

overlayDismisses = false
Expand All @@ -40,7 +40,7 @@ class AlertPopupView: PopupView {
titleLabel = UILabel(frame: CGRect.zero)
titleLabel.textColor = BraveUX.GreyJ
titleLabel.textAlignment = .center
titleLabel.font = UIFont.systemFont(ofSize: 24, weight: UIFont.Weight.bold)
titleLabel.font = UIFont.systemFont(ofSize: titleSize, weight: titleWeight)
titleLabel.text = title
titleLabel.numberOfLines = 0
containerView.addSubview(titleLabel)
Expand Down
22 changes: 14 additions & 8 deletions Client/U2FExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,22 @@ class U2FExtensions: NSObject {

/// Show when user has to touch his auth key
fileprivate let touchKeyPopup = AlertPopupView(imageView: lottieAnimation(for: "webauth_touch_key"),
title: Strings.touchKeyMessage, message: "")
title: Strings.touchKeyMessage, message: "", titleWeight: .semibold, titleSize: 21)

/// Show when user's key hasn't been inserted yet
fileprivate let insertKeyPopup = AlertPopupView(imageView: lottieAnimation(for: "webauth_insert_key"),
title: Strings.insertKeyMessage, message: "")
title: Strings.insertKeyMessage, message: "", titleWeight: .semibold, titleSize: 21)

/// Show to enter key's pin
fileprivate let pinVerificationPopup = AlertPopupView(imageView: UIImageView(image: #imageLiteral(resourceName: "enter_pin")),
title: Strings.pinTitle, message: "",
inputType: .default, secureInput: true,
inputPlaceholder: Strings.pinPlaceholder)
inputPlaceholder: Strings.pinPlaceholder, titleWeight: .semibold, titleSize: 21)

/// Show when key's pin authentication is pending
fileprivate let verificationPendingPopup =
AlertPopupView(imageView: lottieAnimation(for: "webauth_verify_key"),
title: Strings.verificationPending, message: "")
title: Strings.verificationPending, message: "", titleWeight: .semibold, titleSize: 21)

private static func lottieAnimation(for bundleResource: String) -> AnimationView {
let animationView = AnimationView(name: bundleResource).then {
Expand Down Expand Up @@ -651,6 +651,8 @@ class U2FExtensions: NSObject {

// This modal is presented when FIDO/FIDO2 APIs are waiting for the security key
private func presentInsertKeyModal() {
let currentURL = self.tab?.url?.host ?? ""
insertKeyPopup.update(title: Strings.insertKeyMessage + currentURL)
insertKeyPopup.showWithType(showType: .flyUp)
}

Expand All @@ -666,6 +668,8 @@ class U2FExtensions: NSObject {

// The modal should be visible for the tab where the U2F API is active
if u2fActive && tab?.id == currentTabId && (fido2Service.keyState == .touchKey || u2fService.keyState == .YKFKeyU2FServiceKeyStateTouchKey) {
let currentURL = self.tab?.url?.host ?? ""
touchKeyPopup.update(title: Strings.touchKeyMessage + currentURL)
touchKeyPopup.showWithType(showType: .flyUp)
return
}
Expand All @@ -674,7 +678,9 @@ class U2FExtensions: NSObject {

private func handlePinVerificationRequired(completion: @escaping (Bool) -> Void) {
ensureMainThread {
let currentURL = self.tab?.url?.host ?? ""
self.pinVerificationPopup.addButton(title: Strings.confirmPin, type: .primary) { [weak self] in
self?.verificationPendingPopup.update(title: Strings.verificationPending + currentURL)
self?.verificationPendingPopup.showWithType(showType: .flyUp)
return self?.verifyPin(completion: completion) ?? .flyDown
}
Expand Down Expand Up @@ -1177,15 +1183,15 @@ extension Strings {
public static let U2FAuthenticationError = NSLocalizedString("U2FAuthenticationError", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Error authenticating your security key", comment: "Error handling U2F authentication.") + tryAgain

//Lightning Modals
public static let touchKeyMessage = NSLocalizedString("touchKeyMessage", bundle: Bundle.shared, value: "Touch your key to finish.", comment: "Message for touch key modal.")
public static let insertKeyMessage = NSLocalizedString("insertKeyMessage", bundle: Bundle.shared, value: "Insert your security key.", comment: "Message for touch key modal.")
public static let touchKeyMessage = NSLocalizedString("touchKeyMessage", bundle: Bundle.shared, value: "Touch your key to finish the request for ", comment: "Message for touch key modal.")
public static let insertKeyMessage = NSLocalizedString("insertKeyMessage", bundle: Bundle.shared, value: "Insert your security key for ", comment: "Message for touch key modal.")
public static let keyCancel = NSLocalizedString("touchKeyCancel", bundle: Bundle.shared, value: "Cancel", comment: "Text for touch key modal button.")

//PIN
public static let pinTitle = NSLocalizedString("pinTitle", bundle: Bundle.shared, value: "PIN verification required", comment: "Title for the alert modal when a security key with PIN is inserted.")
public static let pinPlaceholder = NSLocalizedString("pinPlaceholder", bundle: Bundle.shared, value: "Enter your security key PIN", comment: "Placeholder text for PIN")
public static let pinPlaceholder = NSLocalizedString("pinPlaceholder", bundle: Bundle.shared, value: "Enter your PIN", comment: "Placeholder text for PIN")
public static let confirmPin = NSLocalizedString("confirmPin", bundle: Bundle.shared, value: "Verify", comment: "Button text to confirm PIN")
public static let verificationPending = NSLocalizedString("verificationPending", bundle: Bundle.shared, value: "Verifying your PIN...", comment: "Title when PIN code is being verified.")
public static let verificationPending = NSLocalizedString("verificationPending", bundle: Bundle.shared, value: "Verifying your PIN for ", comment: "Title when PIN code is being verified.")
}

extension String {
Expand Down

0 comments on commit 4546189

Please sign in to comment.