iOS Sample Applications

Following is a complete iOS sample applications demonstrating both client-direct and backend-proxied FIDO2 authentication patterns. These examples are useful for developers building iOS applications that integrate with the Arculus FIDO2 Server.

Minimal Examples

These minimal examples show the essential code to register and authenticate a user without any UI scaffolding or error handling.

Minimal Client-Direct Example

import ArculusFidoSDKFramework

let arculusFido = ArculusFido()

// Registration
func register() async {
    let fidoServer = ArculusFidoServer(domain: "fido.example.com")
    fidoServer.registrationBeginEndpoint = "fidoapi/certify/attestation/options"
    fidoServer.registrationCompleteEndpoint = "fidoapi/certify/attestation/result"
    
    let result = await arculusFido.registerUser(
        fidoServer: fidoServer,
        pin: "123456",
        username: "[email protected]",
        displayName: "My Device",
        relyingParty: "example.com"
    )
    print("Registration: \(result)")
}

// Authentication
func authenticate() async {
    let fidoServer = ArculusFidoServer(domain: "fido.example.com")
    fidoServer.authorizationBeginEndpoint = "fidoapi/certify/assertion/options"
    fidoServer.authorizationCompleteEndpoint = "fidoapi/certify/assertion/result"
    
    let result = await arculusFido.authenticateUser(
        fidoServer: fidoServer,
        pin: "123456",
        username: "[email protected]",
        displayName: "My Device",
        relyingParty: "example.com"
    )
    print("Authentication: \(result)")
}

Minimal Backend-Proxied Example

Complete Sample Applications

The following sections provide complete, production-ready sample applications with full error handling, UI components, and backend integration.

Client-Direct Pattern

A simple WebView-based sample app demonstrating direct FIDO2 server communication:

A complete sample app demonstrating the backend-proxied pattern with 3-phase authentication and registration flows. This pattern is recommended for production deployments as it provides enhanced security by isolating the FIDO2 server from client applications.

Backend API Client

Complete Backend-Proxied Sample App

Note: The createOptionsResponseFromBackend() helper function constructs an ArculusFidoOptionsAuthorizationResponse from the backend response. The exact implementation may vary based on your SDK version. Refer to your SDK documentation for the specific API methods available.

Backend Implementation (Java Servlet)

The backend service receives requests from the iOS app and proxies them to the FIDO2 Server. Here's a complete Java servlet implementation:

Key Implementation Notes:

  1. Operation-Based Routing: The servlet uses the operation field to route requests to registration or authentication handlers.

  2. Phase Detection: The presence of cardResponseData determines whether it's a "begin" (Phase 1) or "complete" (Phase 3) request.

  3. Session Cookie Management: Cookies from the FIDO2 server are extracted and passed back to the client, then forwarded in subsequent requests.

  4. FIDO2 Server Origin: The backend extracts and returns the FIDO2 server origin URL for the client to use in clientDataJSON validation.

  5. Error Handling: All errors are caught and returned in a consistent JSON format.

Note: This example uses the Arculus SDK server-side methods (ArculusFidoServer) instead of direct REST API calls. For Python backend developers or advanced debugging, see 5.7 FIDO2 Server REST API Reference in the Appendix.

Last updated