{"id":40970594,"url":"https://github.com/coenttb/swift-authenticating","last_synced_at":"2026-01-22T06:43:02.091Z","repository":{"id":269092768,"uuid":"906335974","full_name":"coenttb/swift-authenticating","owner":"coenttb","description":"A Swift package for type-safe HTTP authentication with URL routing integration.","archived":false,"fork":false,"pushed_at":"2025-10-31T10:27:44.000Z","size":42,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-31T12:18:24.645Z","etag":null,"topics":["authentication","http","swift","type-safe","url-routing"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coenttb.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}},"created_at":"2024-12-20T17:07:35.000Z","updated_at":"2025-10-31T12:16:19.000Z","dependencies_parsed_at":"2025-01-22T08:26:31.148Z","dependency_job_id":"0017c7e5-18e8-48dc-9be3-ee650cf3ca59","html_url":"https://github.com/coenttb/swift-authenticating","commit_stats":null,"previous_names":["coenttb/swift-basic-auth","coenttb/swift-authenticating"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coenttb/swift-authenticating","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-authenticating","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-authenticating/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-authenticating/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-authenticating/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coenttb","download_url":"https://codeload.github.com/coenttb/swift-authenticating/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-authenticating/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28657110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":["authentication","http","swift","type-safe","url-routing"],"created_at":"2026-01-22T06:43:01.563Z","updated_at":"2026-01-22T06:43:02.079Z","avatar_url":"https://github.com/coenttb.png","language":"Swift","readme":"# swift-authenticating\n\n[![CI](https://github.com/coenttb/swift-authenticating/workflows/CI/badge.svg)](https://github.com/coenttb/swift-authenticating/actions/workflows/ci.yml)\n![Development Status](https://img.shields.io/badge/status-active--development-blue.svg)\n\nType-safe HTTP authentication with URL routing integration for Swift.\n\n## Overview\n\n`swift-authenticating` provides type-safe HTTP authentication types and URL routers, supporting both Basic (RFC 7617) and Bearer (RFC 6750) authentication schemes. Built on Point-Free's [swift-url-routing](https://github.com/pointfreeco/swift-url-routing) and [swift-dependencies](https://github.com/pointfreeco/swift-dependencies), it enables composable and testable API authentication patterns.\n\n## Features\n\n- Type-safe authentication with compile-time guarantees via Swift's type system\n- URL routing integration via swift-url-routing ParserPrinter protocol\n- RFC 7617 Basic Authentication support with base64 credential encoding\n- RFC 6750 Bearer Token Authentication support\n- Email address support for Basic Authentication via EmailAddress type\n- Generic Authenticating struct for custom authentication schemes\n- Full swift-dependencies integration for testability\n- Swift 6.0 concurrency support with Sendable conformance\n\n## Installation\n\nAdd `swift-authenticating` to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/coenttb/swift-authenticating\", from: \"0.0.1\")\n]\n```\n\nThen add the product to your target:\n\n```swift\n.target(\n    name: \"YourTarget\",\n    dependencies: [\n        .product(name: \"Authenticating\", package: \"swift-authenticating\")\n    ]\n)\n```\n\n## Quick Start\n\n### Basic Authentication\n\n```swift\nimport Authenticating\n\n// Create basic auth credentials\nlet auth = try BasicAuth(username: \"api\", password: \"secret-key\")\n\n// Use with URL routing to generate Authorization header\nlet router = BasicAuth.Router()\nlet requestData = try router.print(auth)\n// requestData.headers[\"Authorization\"] contains \"Basic \u003cbase64\u003e\"\n```\n\n### Bearer Token Authentication\n\n```swift\nimport Authenticating\n\n// Create bearer token\nlet auth = try BearerAuth(token: \"your-api-token\")\n\n// Use with URL routing to generate Authorization header\nlet router = BearerAuth.Router()\nlet requestData = try router.print(auth)\n// requestData.headers[\"Authorization\"] contains \"Bearer your-api-token\"\n```\n\n## Usage Examples\n\n### Email-based Basic Authentication\n\n```swift\nimport Authenticating\n\nlet email = try EmailAddress(\"user@example.com\")\nlet auth = try BasicAuth(emailAddress: email, password: \"password123\")\n```\n\n### Creating an Authenticated Client\n\n```swift\nimport Authenticating\nimport Dependencies\nimport URLRouting\n\n// Define your API routes\nenum MyAPI: Equatable {\n    case getUser(id: String)\n    case updateProfile(name: String)\n}\n\n// Create router for your API\nstruct MyAPIRouter: ParserPrinter {\n    var body: some URLRouting.Router\u003cMyAPI\u003e {\n        OneOf {\n            Route(.case(MyAPI.getUser)) {\n                Path { \"users\"; Parse(.string) }\n            }\n            Route(.case(MyAPI.updateProfile)) {\n                Method.post\n                Path { \"profile\" }\n                Body(.form(name: .string))\n            }\n        }\n    }\n}\n\n// Create authenticated client\nlet authenticating = try Authenticating(\n    baseURL: URL(string: \"https://api.example.com\")!,\n    username: \"api\",\n    password: \"secret-key\",\n    buildClient: { requestBuilder in\n        // Return your client implementation\n        // requestBuilder closure converts MyAPI -\u003e URLRequest\n        return myClientImplementation\n    }\n)\n\n// Access client and router\nlet client = authenticating.client\nlet router = authenticating.router\n```\n\n### API Key Authentication (Mailgun-style)\n\n```swift\nimport Authenticating\n\n// Many APIs use \"api\" as username with API key as password\nlet authenticating = try Authenticating(\n    baseURL: URL(string: \"https://api.mailgun.net\")!,\n    apiKey: \"key-1234567890abcdef\",\n    buildClient: { requestBuilder in\n        // Build your client\n        return mailgunClient\n    }\n)\n```\n\n## Module Reference\n\n### Authenticating\n\nCore module providing generic authentication types:\n\n- `Authenticating\u003cAuth, AuthRouter, API, APIRouter, ClientOutput\u003e` - Generic authentication container with client and router\n- `BasicAuth` - Type alias for RFC_7617.Basic\n- `BearerAuth` - Type alias for RFC_6750.Bearer\n\n### AuthenticatingURLRouting\n\nURL routing implementations for authentication schemes:\n\n- `BasicAuth.Router` - ParserPrinter for RFC 7617 Basic Authentication\n- `BasicAuth.ParserPrinter` - Credential encoding/decoding for Basic auth\n- `BearerAuth.Router` - ParserPrinter for RFC 6750 Bearer Token authentication\n- `BearerAuth.ParserPrinter` - Token encoding/decoding for Bearer auth\n\n### AuthenticatingEmailAddress\n\nEmail address support for authentication:\n\n- `BasicAuth.init(emailAddress:password:)` - Convenience initializer using EmailAddress as username\n\n## Requirements\n\n- Swift 6.0+\n- macOS 14.0+ / iOS 17.0+\n\n## Related Packages\n\n### Dependencies\n\n- [swift-emailaddress-type](https://github.com/coenttb/swift-emailaddress-type): A Swift package with a type-safe EmailAddress model.\n\n### Used By\n\n- [swift-github-live](https://github.com/coenttb/swift-github-live): A Swift package with live implementations for the GitHub API.\n- [swift-identities-types](https://github.com/coenttb/swift-identities-types): A Swift package with foundational types for authentication.\n- [swift-mailgun-live](https://github.com/coenttb/swift-mailgun-live): A Swift package with live implementations for Mailgun.\n- [swift-stripe](https://github.com/coenttb/swift-stripe): The Swift library for the Stripe API.\n- [swift-stripe-live](https://github.com/coenttb/swift-stripe-live): A Swift package with live implementations for the Stripe API.\n\n### Third-Party Dependencies\n\n- [pointfreeco/swift-dependencies](https://github.com/pointfreeco/swift-dependencies): A dependency management library for controlling dependencies in Swift.\n- [pointfreeco/swift-url-routing](https://github.com/pointfreeco/swift-url-routing): A bidirectional URL router with more type safety and less fuss.\n\n## License\n\nThis project is licensed under the Apache 2.0 License. See [LICENSE](LICENSE) for details.\n\n## Contributing\n\nContributions are welcome. Please open an issue or pull request.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-authenticating","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoenttb%2Fswift-authenticating","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-authenticating/lists"}