{"id":20844496,"url":"https://github.com/pushpabrol/appattesttestauth0login","last_synced_at":"2026-04-28T04:38:09.176Z","repository":{"id":252843575,"uuid":"820455457","full_name":"pushpabrol/AppAttestTestAuth0Login","owner":"pushpabrol","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-26T15:05:38.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-30T11:35:38.615Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pushpabrol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-26T13:56:21.000Z","updated_at":"2024-08-12T18:51:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"8088d2da-22ff-4466-a365-cc1143adad27","html_url":"https://github.com/pushpabrol/AppAttestTestAuth0Login","commit_stats":null,"previous_names":["pushpabrol/appattesttestauth0login"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pushpabrol/AppAttestTestAuth0Login","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpabrol%2FAppAttestTestAuth0Login","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpabrol%2FAppAttestTestAuth0Login/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpabrol%2FAppAttestTestAuth0Login/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpabrol%2FAppAttestTestAuth0Login/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pushpabrol","download_url":"https://codeload.github.com/pushpabrol/AppAttestTestAuth0Login/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpabrol%2FAppAttestTestAuth0Login/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32367021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T02:09:48.426Z","updated_at":"2026-04-28T04:38:09.165Z","avatar_url":"https://github.com/pushpabrol.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# App Attest, app assertion verification with auth0 endpoints \n\nThis SwiftUI project demonstrates the implementation of Apple's App Attest feature alongside the Proof Key for Code Exchange (PKCE) flow to securely authenticate users. It involves device attestation and  assertion verification with auth0 endpoints via a proxy - for validating attestations and handling assertion checks for user authentication calls. this project assumes auth0 is behind a proxy with code in the proxy to handle attestation, assertion verification based on the attestation as well as using private key jwt for client authentication - example [Cloudflare proxy code](https://github.com/pushpabrol/cloudflare-worker-auth0-app-attest)\n\n## Features\n\n- **Apple App Attest**: Ensures the app's integrity and validates that the app has not been tampered with.\n- **PKCE Flow**: Enhances OAuth 2.0 security by using a code verifier and code challenge.\n- **SwiftUI Interface**: Provides a modern and user-friendly interface using SwiftUI.\n- **Secure Storage**: Utilizes Keychain for secure storage of sensitive information.\n- **Add assertions**: Adds assertions using app attest service for calls to /authorize and /oauth/token\n\n## Requirements\n\n- iOS 14.0+\n- Xcode 12.0+\n- Swift 5.3+\n\n## Installation\n\n1. **Clone the repository**:\n2. **Open the project** in Xcode:\n   ```bash\n   open AppAttestExample.xcodeproj\n   ```\n3. **Build and run** the application on a compatible iOS device.\n\n## Configuration\n\n1. **Config.plist**: Ensure you have the following keys set in your `Config.plist` file:\n   - `AttestationChallengeURL`\n   - `VerifyAttestationURL`\n   - `CLIENT_ID`\n   - `REDIRECT_URI`\n   - `AUTH_ENDPOINT`\n   - `TOKEN_ENDPOINT`\n   - `AssertionChallengeURL`\n\n## Usage\n\n1. **App Initialization**:\n   - On launch, the app initializes the attestation key and checks if the device is attested.\n   - If the attestation is successful, the app indicates readiness for login.\n\n2. **User Login**:\n   - The user can log in using the PKCE flow.\n   - The login process involves creating a code verifier and code challenge, generating an assertion, and initiating an authorization request.\n\n3. **Assumptions**:\n   - This is a very targeted solution \n   - The user can log out, which clears the session data.\n\n## Classes and Methods\n\n### `AppAttestViewModel`\n\n- **Properties**:\n  - `@Published var isLoading`: Tracks the loading state.\n  - `@Published var showAlert`: Controls the display of alerts.\n  - `@Published var alertMessage`: Message displayed in alerts.\n  - `@Published var keyIdentifier`: Stores the key identifier.\n  - `@Published var isUserLoggedIn`: Tracks the user's login status.\n  - `@Published var attestationChallenge`: Stores the attestation challenge.\n  - `@Published var tokenData`: Stores the authentication token data.\n  - `@Published var appAttested`: Indicates if the app is attested.\n\n- **Methods**:\n  - `func logout()`: Logs the user out.\n  - `func loadConfigValue(forKey key: String) -\u003e String`: Loads configuration values from `Config.plist`.\n  - `func initializeAttestationKey()`: Initializes the attestation key.\n  - `func generateAttestationKey() async`: Generates a new attestation key.\n  - `func handleError(_ error: Error)`: Handles errors by displaying appropriate messages.\n  - `func startPKCEFlow() async`: Initiates the PKCE flow.\n  - `func requestAttestationChallenge() async`: Requests an attestation challenge from the server.\n  - `func urlSafeBase64Encode(_ data: Data) -\u003e String`: Encodes data in URL-safe base64.\n  - `func verifyAttestation() async`: Verifies the attestation with the server.\n  - `func initiateAuthorizationRequest(codeVerifier: String, codeChallenge: String, clientData: Data, keyId: String, assertion: Data) async`: Initiates an authorization request.\n  - `func exchangeCodeForToken(code: String, codeVerifier: String, clientData: Data, keyId: String, assertion: Data) async`: Exchanges authorization code for tokens.\n  - `func generateCodeVerifier() -\u003e String`: Generates a PKCE code verifier.\n  - `func generateCodeChallenge(codeVerifier: String) -\u003e String`: Generates a PKCE code challenge.\n  - `func createAssertion() async -\u003e (String, Data, Data)?`: Creates an assertion for the attestation.\n  - `func requestAssertionChallenge() async -\u003e String?`: Requests an assertion challenge from the server.\n\n### `ContentView`\n\n- **Properties**:\n  - `@StateObject var viewModel`: An instance of `AppAttestViewModel`.\n\n- **Methods**:\n  - `var body: some View`: The main view that displays the attestation status, login button, and user information.\n  - `private func keyIdentifierSection(keyIdentifier: String) -\u003e some View`: Displays the key identifier.\n  - `private func loggedInView() -\u003e some View`: Displays the user's login status and token information.\n\n### `PrimaryButtonStyle`\n\nA custom button style for consistent button appearance.\n\n```swift\nstruct PrimaryButtonStyle: ButtonStyle {\n    func makeBody(configuration: Self.Configuration) -\u003e some View {\n        configuration.label\n            .padding()\n            .background(Color.blue)\n            .foregroundColor(.white)\n            .cornerRadius(8)\n    }\n}\n```\n\n## Security\n\nThis project uses several security measures:\n- **App Attest**: Ensures the app's integrity.\n- **Keychain**: Sensitive data like tokens are stored securely in the iOS Keychain.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushpabrol%2Fappattesttestauth0login","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpushpabrol%2Fappattesttestauth0login","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushpabrol%2Fappattesttestauth0login/lists"}