Skip to content

Commit

Permalink
NEVISACCESSAPP-5981: Added Password authenticator capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-gulyas committed Jul 9, 2024
1 parent 8f89920 commit af41297
Show file tree
Hide file tree
Showing 52 changed files with 1,785 additions and 787 deletions.
178 changes: 89 additions & 89 deletions NevisExampleApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1540"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
62 changes: 52 additions & 10 deletions NevisExampleApp/Application/Dependency Provider/AppAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ extension AppAssembly: Assembly {

private extension AppAssembly {

// MARK: Screens

/// Registers the screens.
///
/// - Parameter container: The container provided by the `Assembler`.
Expand Down Expand Up @@ -69,8 +71,8 @@ private extension AppAssembly {
argument: arg))
}.inObjectScope(.weak)

container.register(PinScreen.self) { (res: Resolver, arg: NavigationParameterizable) in
PinScreen(viewModel: res ~> (PinViewModel.self, argument: arg))
container.register(CredentialScreen.self) { (res: Resolver, arg: NavigationParameterizable) in
CredentialScreen(viewModel: res ~> (CredentialViewModel.self, argument: arg))
}.inObjectScope(.weak)

container.register(TransactionConfirmationScreen.self) { (res: Resolver, arg: NavigationParameterizable) in
Expand All @@ -93,6 +95,8 @@ private extension AppAssembly {
.inObjectScope(.container)
}

// MARK: Coordinators

/// Registers the coordinators.
///
/// - Parameter container: The container provided by the `Assembler`.
Expand All @@ -102,6 +106,8 @@ private extension AppAssembly {
.inObjectScope(.container)
}

// MARK: View models

/// Registers the view models.
///
/// - Parameter container: The container provided by the `Assembler`.
Expand Down Expand Up @@ -141,9 +147,9 @@ private extension AppAssembly {
initializer: SelectAuthenticatorViewModel.init)
.inObjectScope(.transient)

container.autoregister(PinViewModel.self,
container.autoregister(CredentialViewModel.self,
argument: NavigationParameterizable.self,
initializer: PinViewModel.init)
initializer: CredentialViewModel.init)
.inObjectScope(.transient)

container.autoregister(TransactionConfirmationViewModel.self,
Expand All @@ -166,6 +172,8 @@ private extension AppAssembly {
.inObjectScope(.transient)
}

// MARK: Use-cases

/// Registers the use cases.
///
/// - Parameter container: The container provided by the `Assembler`.
Expand All @@ -188,6 +196,8 @@ private extension AppAssembly {
authenticationAuthenticatorSelector: authSelectorForAuth,
pinEnroller: res~>,
pinUserVerifier: res~>,
passwordEnroller: res~>,
passwordUserVerifier: res~>,
biometricUserVerifier: res~>,
devicePasscodeUserVerifier: res~>,
logger: res~>)
Expand All @@ -200,6 +210,7 @@ private extension AppAssembly {
createDeviceInformationUseCase: res~>,
authenticatorSelector: authenticatorSelector,
pinEnroller: res~>,
passwordEnroller: res~>,
biometricUserVerifier: res~>,
devicePasscodeUserVerifier: res~>,
logger: res~>)
Expand All @@ -211,6 +222,7 @@ private extension AppAssembly {
return InBandAuthenticationUseCaseImpl(clientProvider: res~>,
authenticatorSelector: authenticatorSelector,
pinUserVerifier: res~>,
passwordUserVerifier: res~>,
biometricUserVerifier: res~>,
devicePasscodeUserVerifier: res~>,
logger: res~>)
Expand All @@ -222,13 +234,17 @@ private extension AppAssembly {
container.autoregister(ChangePinUseCase.self,
initializer: ChangePinUseCaseImpl.init)

container.autoregister(ChangePasswordUseCase.self,
initializer: ChangePasswordUseCaseImpl.init)

container.register(AuthCloudApiRegistrationUseCase.self) { res in
let authenticatorSelector = res ~> (AuthenticatorSelector.self,
name: RegistrationAuthenticatorSelectorName)
return AuthCloudApiRegistrationUseCaseImpl(clientProvider: res~>,
createDeviceInformationUseCase: res~>,
authenticatorSelector: authenticatorSelector,
pinEnroller: res~>,
passwordEnroller: res~>,
biometricUserVerifier: res~>,
devicePasscodeUserVerifier: res~>,
logger: res~>)
Expand Down Expand Up @@ -256,6 +272,8 @@ private extension AppAssembly {
initializer: LoginUseCaseImpl.init)
}

// MARK: Repositories

/// Registers the repositories.
///
/// - Parameter container: The container provided by the `Assembler`.
Expand All @@ -264,6 +282,8 @@ private extension AppAssembly {
initializer: LoginRepositoryImpl.init)
}

// MARK: Data sources

/// Registers the data sources.
///
/// - Parameter container: The container provided by the `Assembler`.
Expand All @@ -272,6 +292,8 @@ private extension AppAssembly {
initializer: LoginDataSourceImpl.init)
}

// MARK: Components

/// Registers the components.
///
/// - Parameter container: The container provided by the `Assembler`.
Expand All @@ -287,13 +309,21 @@ private extension AppAssembly {
container.autoregister(AccountSelector.self,
initializer: AccountSelectorImpl.init)

container.autoregister(AuthenticatorSelector.self,
name: AuthenticationAuthenticatorSelectorName,
initializer: AuthenticationAuthenticatorSelectorImpl.init)
container.register(AuthenticatorSelector.self,
name: AuthenticationAuthenticatorSelectorName) { res in
AuthenticatorSelectorImpl(authenticatorValidator: res~>,
operation: .authentication,
responseEmitter: res~>,
logger: res~>)
}

container.autoregister(AuthenticatorSelector.self,
name: RegistrationAuthenticatorSelectorName,
initializer: RegistrationAuthenticatorSelectorImpl.init)
container.register(AuthenticatorSelector.self,
name: RegistrationAuthenticatorSelectorName) { res in
AuthenticatorSelectorImpl(authenticatorValidator: res~>,
operation: .registration,
responseEmitter: res~>,
logger: res~>)
}

container.autoregister(PinEnroller.self,
initializer: PinEnrollerImpl.init)
Expand All @@ -304,6 +334,15 @@ private extension AppAssembly {
container.autoregister(PinUserVerifier.self,
initializer: PinUserVerifierImpl.init)

container.autoregister(PasswordEnroller.self,
initializer: PasswordEnrollerImpl.init)

container.autoregister(PasswordChanger.self,
initializer: PasswordChangerImpl.init)

container.autoregister(PasswordUserVerifier.self,
initializer: PasswordUserVerifierImpl.init)

container.autoregister(BiometricUserVerifier.self,
initializer: BiometricUserVerifierImpl.init)

Expand All @@ -321,6 +360,9 @@ private extension AppAssembly {
container.autoregister(AccountValidator.self,
initializer: AccountValidatorImpl.init)

container.autoregister(AuthenticatorValidator.self,
initializer: AuthenticatorValidatorImpl.init)

container.autoregister(SDKLogger.self,
initializer: SDKLoggerImpl.init)
.inObjectScope(.container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ struct AppConfiguration: Codable {
/// The Nevis Mobile Authentication SDK configuration.
let sdkConfiguration: Configuration

/// The allowed authenticators. /// The allowed authenticators.
let authenticatorWhitelist: [AuthenticatorAaid]

// MARK: - CodingKey

/// Enumeration for keys used during coding.
Expand All @@ -25,6 +28,8 @@ struct AppConfiguration: Codable {
case loginConfiguration = "login"
/// Key for the SDK configuration.
case sdkConfiguration = "sdk"
/// Key for the authenticator whitelist.
case authenticatorWhitelist

/// Enumeration for the nested SDK configuration keys used during coding.
enum NestedCodingKeys: String, CodingKey {
Expand Down Expand Up @@ -73,5 +78,6 @@ struct AppConfiguration: Codable {
else {
self.sdkConfiguration = try container.decode(Configuration.self, forKey: .sdkConfiguration)
}
self.authenticatorWhitelist = try container.decode([AuthenticatorAaid].self, forKey: .authenticatorWhitelist)
}
}
4 changes: 2 additions & 2 deletions NevisExampleApp/Common/Configuration/Model/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ enum Environment {
/// The configuration file name for an environment.
var configFileName: String {
switch self {
case .authenticationCloud: return "ConfigAuthenticationCloud"
case .identitySuite: return "ConfigIdentitySuite"
case .authenticationCloud: "ConfigAuthenticationCloud"
case .identitySuite: "ConfigIdentitySuite"
}
}
}
16 changes: 12 additions & 4 deletions NevisExampleApp/Common/Error/AppError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ enum AppError: Error {
case cookieNotFound
/// No PIN authenticator found in the list of registered authenticators.
case pinAuthenticatorNotFound
/// No Password authenticator found in the list of registered authenticators.
case passwordAuthenticatorNotFound
/// Unknown error.
case unknown
}

// MARK: - LocalizedError
Expand All @@ -24,13 +28,17 @@ extension AppError: LocalizedError {
public var errorDescription: String? {
switch self {
case .loadAppConfigurationError:
return L10n.Error.App.loadAppConfigurationError
L10n.Error.App.loadAppConfigurationError
case .readLoginConfigurationError:
return L10n.Error.App.readLoginConfigurationError
L10n.Error.App.readLoginConfigurationError
case .cookieNotFound:
return L10n.Error.App.cookieNotFound
L10n.Error.App.cookieNotFound
case .pinAuthenticatorNotFound:
return L10n.Error.App.pinAuthenticatorNotFound
L10n.Error.App.pinAuthenticatorNotFound
case .passwordAuthenticatorNotFound:
L10n.Error.App.passwordAuthenticatorNotFound
case .unknown:
L10n.Error.App.Generic.message
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ extension Authenticator {
func isEnrolled(username: Username) -> Bool {
switch userEnrollment {
case let enrollment as SdkUserEnrollment:
return enrollment.isEnrolled(username)
enrollment.isEnrolled(username)
case let enrollment as OsUserEnrollment:
return enrollment.isEnrolled()
enrollment.isEnrolled()
default:
return false
false
}
}
}
12 changes: 4 additions & 8 deletions NevisExampleApp/Domain/Interaction/AccountSelectorImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class AccountSelectorImpl {
/// The response emitter.
private let responseEmitter: ResponseEmitter

/// The error handler chain.
private let errorHandlerChain: ErrorHandlerChain

/// The logger.
private let logger: SDKLogger

Expand All @@ -36,15 +33,13 @@ class AccountSelectorImpl {
/// - Parameters:
/// - accountValidator: The account validator.
/// - responseEmitter: The response emitter.
/// - errorHandlerChain: The error handler chain.
/// - responseEmitter: The response emitter.
/// - logger: The logger.
init(accountValidator: AccountValidator,
responseEmitter: ResponseEmitter,
errorHandlerChain: ErrorHandlerChain,
errorHandlerChain _: ErrorHandlerChain,
logger: SDKLogger) {
self.accountValidator = accountValidator
self.responseEmitter = responseEmitter
self.errorHandlerChain = errorHandlerChain
self.logger = logger
}
}
Expand Down Expand Up @@ -90,7 +85,8 @@ extension AccountSelectorImpl: AccountSelector {
}
}
catch {
errorHandlerChain.handle(error: error)
logger.log("Authenticator selection failed due to \(error.localizedDescription)", color: .red)
handler.cancel()
}
}
}

This file was deleted.

Loading

0 comments on commit af41297

Please sign in to comment.