AuthKit is a powerful authentication framework that provides easy-to-use methods for user authentication in your iOS application. It supports various authentication methods such as OAuth, Featherweight, and basic authentication.
- Authenticate users using email and password with OAuth, Featherweight, or basic authentication methods.
- Reauthenticate users using OAuth refresh tokens.
- Unauthenticate users and clear their session.
- Generate and manage RSA key pairs for code verification.
- Sign code challenge strings using RSA keys.
- Set bearer tokens manually for custom authentication scenarios.
You can install AuthKit using Swift Package Manager. Follow these steps:
- In Xcode, open your project.
- Go to "File" -> "Swift Packages" -> "Add Package Dependency".
- Paste the following URL:
https://github.com/wolfej94/AuthKit
. - Click "Next" and select the desired version rule.
- Click "Next" and then "Finish".
- Import AuthKit in your Swift files:
import AuthKit
.
To get started with AuthKit, initialize an instance of the AuthKit
class with your desired configuration:
let bundle = "com.yourapp.bundle"
let prompt = "Enter your passphrase"
let method = AuthenticationMethod.basic
let baseURL = URL(string: "https://example.com")!
let authKit = AuthKit(bundle: bundle, prompt: prompt, method: method, baseURL: baseURL)
Authenticate a user by providing their email and password:
let path = "/api/login"
let email = "[email protected]"
let password = "secretpassword"
try authKit.authenticate(path: path, email: email, password: password)
Reauthenticate a user using OAuth refresh tokens:
let path = "/api/refresh-token"
try authKit.reauthenticate(path: path)
Unauthenticate a user and clear their session:
try authKit.unauthenticate()
Generate a new RSA key pair for code verification:
let publicKey = try authKit.generateKeyPair()
Sign a code challenge string using the RSA key pair:
let challenge = "examplechallenge"
let signedChallenge = try authKit.sign(challenge: challenge)
Manually set the bearer token for custom authentication scenarios:
let token = "your-bearer-token"
try authKit.setBearerToken(to: token)
We welcome contributions to improve AuthKit and make it even more powerful and user-friendly. If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on GitHub.
AuthKit is released under the MIT License. See LICENSE for details.
AuthKit is created and maintained by James Wolfe.
We would like to thank the following open-source projects for their inspiration and contributions:
For any inquiries or questions, please contact James Wolfe.