Authentication

public protocol Authentication : HttpOperation

The object that can be used to trigger an authentication operation.

Usage example:

class AuthenticatorSelectorImpl: AuthenticatorSelector {
    func selectAuthenticator(context: AuthenticatorSelectionContext, handler: AuthenticatorSelectionHandler) {
        handler.aaid(aaid)
    }
}

class BiometricUserVerifierImpl: BiometricUserVerifier {
    func verifyBiometric(context: BiometricUserVerificationContext, handler: BiometricUserVerificationHandler) {
        handler.verify()
    }
}

class DevicePasscodeUserVerifierImpl: DevicePasscodeUserVerifier {
    func verifyDevicePasscode(context: DevicePasscodeUserVerificationContext, handler: DevicePasscodeUserVerificationHandler) {
        handler.verify()
    }
}

class PinUserVerifierImpl: PinUserVerifier {
    func verifyPin(context: PinUserVerificationContext, handler: PinUserVerificationHandler) {
        handler.verify(pin: pin)
    }
}

client.operations.authentication
    .username(username)
    .authenticatorSelector(AuthenticatorSelectorImpl(...))
    .biometricUserVerifier(BiometricUserVerifierImpl(...))
    .devicePasscodeUserVerifier(DevicePasscodeUserVerifierImpl(...))
    .pinUserVerifier(PinUserVerifierImpl(...))
    .onError { error in
        ...
    }
    .onSuccess { authorizationProvider in
        ...
    }
    .execute()
  • Specifies the username that must be used to authenticate.

    Important

    Providing the username is required.

    Declaration

    Swift

    @discardableResult
    func username(_ username: String) -> Authentication

    Parameters

    username

    the username.

    Return Value

    the Authentication builder.

  • Specifies the session provider that must be used to authenticate.

    Declaration

    Swift

    @discardableResult
    func sessionProvider(_ sessionProvider: SessionProvider) -> Authentication

    Parameters

    sessionProvider

    Return Value

    the Authentication builder.

  • The retry policy to be used to obtain an AuthorizationProvider after the user authenticates successfully. If obtaining an AuthorizationProvider fails on the first try, the SDK will retry according to the provided RetryPolicy.

    Declaration

    Swift

    @discardableResult
    func retryPolicyObtainingAuthorizationProvider(_ retryPolicy: RetryPolicy) -> Authentication

    Parameters

    retryPolicy

    the retry policy to be used when retrieving the AuthorizationProvider. By default, the code will retry 3 times with a time interval of 1 second between tries.

    Return Value

    the Authentication builder.

  • Specifies the object that will take care of the selection of the authenticator to be used.

    Important

    Providing the authenticator selector is required.

    Declaration

    Swift

    @discardableResult
    func authenticatorSelector(_ authenticatorSelector: AuthenticatorSelector) -> Self

    Parameters

    authenticatorSelector

    Return Value

    the Authentication builder.

  • Specifies the object that will take care of the biometric user verification.

    Important

    Providing at least one of the BiometricUserVerifier, DevicePasscodeUserVerifier or PinUserVerifier is required.

    Declaration

    Swift

    @discardableResult
    func biometricUserVerifier(_ biometricUserVerifier: BiometricUserVerifier) -> Self

    Parameters

    biometricUserVerifier

    Return Value

    the Authentication builder.

  • Specifies the object that will take care of the device passcode user verification.

    Important

    Providing at least one of the BiometricUserVerifier, DevicePasscodeUserVerifier or PinUserVerifier is required.

    Declaration

    Swift

    @discardableResult
    func devicePasscodeUserVerifier(_ devicePasscodeUserVerifier: DevicePasscodeUserVerifier) -> Self

    Parameters

    devicePasscodeUserVerifier

    Return Value

    the Authentication builder.

  • Specifies the object that will take care of the PIN user verification.

    Important

    Providing at least one of the BiometricUserVerifier, DevicePasscodeUserVerifier or PinUserVerifier is required.

    Declaration

    Swift

    @discardableResult
    func pinUserVerifier(_ pinUserVerifier: PinUserVerifier) -> Authentication

    Parameters

    pinUserVerifier

    Return Value

    the Authentication builder.

  • Specifies the block to execute if the authentication was successful. This object will be invoked in the DispatchQueue.main thread.

    Important

    Providing the onSuccess block is required.

    Declaration

    Swift

    @discardableResult
    func onSuccess(_ onSuccess: @escaping (AuthorizationProvider?) -> ()) -> Authentication

    Parameters

    onSuccess

    the block to execute on successful authentication, receives an optional AuthorizationProvider.

    Return Value

    the Authentication builder.

  • Specifies the block to execute if the authentication failed. This object will be invoked in the DispatchQueue.main thread.

    Important

    Providing the onError block is required.

    Declaration

    Swift

    @discardableResult
    func onError(_ onError: @escaping (AuthenticationError) -> ()) -> Authentication

    Parameters

    onError

    the block to execute on failed authentication, receives an AuthenticationError.

    Return Value

    the Authentication builder.