-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEVISACCESSAPP-5981: Added Password authenticator capabilities
- Loading branch information
1 parent
d657965
commit 59d2dd2
Showing
38 changed files
with
1,387 additions
and
613 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
NevisExampleApp.xcodeproj/xcshareddata/xcschemes/NevisExampleApp.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 0 additions & 63 deletions
63
NevisExampleApp/Interaction/AuthenticationAuthenticatorSelectorImpl.swift
This file was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
NevisExampleApp/Interaction/AuthenticatorSelectorImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// Nevis Mobile Authentication SDK Example App | ||
// | ||
// Copyright © 2022. Nevis Security AG. All rights reserved. | ||
// | ||
|
||
import NevisMobileAuthentication | ||
|
||
/// The unique name of authenticator selector implementation for Registration operation. | ||
let RegistrationAuthenticatorSelectorName = "auth_selector_reg" | ||
|
||
/// The unique name of authenticator selector implementation for Authentication operation. | ||
let AuthenticationAuthenticatorSelectorName = "auth_selector_auth" | ||
|
||
/// Default implementation of ``AuthenticatorSelector`` protocol used for authentication. | ||
/// | ||
/// Navigates to the ``SelectAuthenticatorScreen`` where the user can select from the available authenticators. | ||
class AuthenticatorSelectorImpl { | ||
|
||
enum Operation { | ||
case registration | ||
case authentication | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
/// The application coordinator. | ||
private let appCoordinator: AppCoordinator | ||
|
||
/// The logger. | ||
private let logger: SDKLogger | ||
|
||
/// The configuration loader. | ||
private let configurationLoader: ConfigurationLoader | ||
|
||
/// The mode of the current operation. | ||
private let operation: Operation | ||
|
||
// MARK: - Initialization | ||
|
||
/// Creates a new instance. | ||
/// | ||
/// - Parameters: | ||
/// - appCoordinator: The application coordinator. | ||
/// - logger: The logger. | ||
/// - configurationLoader: The configuration loader. | ||
init(appCoordinator: AppCoordinator, | ||
logger: SDKLogger, | ||
configurationLoader: ConfigurationLoader, | ||
operation: Operation) { | ||
self.appCoordinator = appCoordinator | ||
self.logger = logger | ||
self.configurationLoader = configurationLoader | ||
self.operation = operation | ||
} | ||
} | ||
|
||
// MARK: - AuthenticatorSelector | ||
|
||
extension AuthenticatorSelectorImpl: AuthenticatorSelector { | ||
func selectAuthenticator(context: AuthenticatorSelectionContext, handler: AuthenticatorSelectionHandler) { | ||
guard let configuration = try? configurationLoader.load() else { | ||
logger.log("Configuration cannot be loaded during authenticator selection!", color: .red) | ||
return handler.cancel() | ||
} | ||
|
||
logger.log("Please select one of the received available authenticators!") | ||
|
||
let validator = AuthenticatorValidator() | ||
let validationResult = switch operation { | ||
case .registration: validator.validateForRegistration(context: context, whitelistedAuthenticators: configuration.authenticatorWhitelist) | ||
case .authentication: validator.validateForAuthentication(context: context, whitelistedAuthenticators: configuration.authenticatorWhitelist) | ||
} | ||
|
||
switch validationResult { | ||
case let .success(validatedAuthenticators): | ||
let authenticatorItems = validatedAuthenticators.map { | ||
AuthenticatorItem(authenticator: $0, | ||
isPolicyCompliant: context.isPolicyCompliant(authenticatorAaid: $0.aaid), | ||
isUserEnrolled: $0.isEnrolled(username: context.account.username)) | ||
} | ||
let parameter: SelectAuthenticatorParameter = .select(authenticatorItems: authenticatorItems, | ||
handler: handler) | ||
if case .registration = operation { | ||
appCoordinator.topScreen?.enableInteraction() | ||
} | ||
appCoordinator.navigateToAuthenticatorSelection(with: parameter) | ||
case .failure: | ||
handler.cancel() | ||
} | ||
} | ||
} |
Oops, something went wrong.