5 stable releases
| 1.0.4 | Sep 24, 2025 |
|---|---|
| 1.0.2 | Sep 9, 2025 |
| 1.0.1 | Aug 16, 2025 |
| 1.0.0 | Aug 15, 2025 |
#429 in GUI
247 downloads per month
50KB
644 lines
Tauri Plugin PLAUTH
A Tauri plugin for authentication (PLAUTH) that currently supports macOS and iOS platforms only. The plugin implements ASWebAuthenticationSession for secure web-based authentication flows.
Platform Support
| Platform | Status | Notes |
|---|---|---|
| macOS | ✅ Full | Web view integration |
| iOS | ❌ Full | ASWebAuthenticationSession |
| Android | ❌ Not supported | Not planned |
| Linux | ❌ Not supported | Not planned |
| Windows | ❌ Not supported | Not planned |
Features
- macOS: Full support with web view integration and ASWebAuthenticationSession
- iOS: Full support with ASWebAuthenticationSession and UIKit integration
- Android: Not currently supported
- Linux: Not currently supported
- Windows: Not currently supported
Installation
Rust Dependencies
Add the following to your Cargo.toml:
[dependencies]
tauri-plugin-plauth = "1.0.0"
Or use the cargo add command:
cargo add tauri-plugin-plauth
JavaScript/TypeScript Dependencies
npm install tauri-plugin-plauth-api
# or
yarn add tauri-plugin-plauth-api
Usage
Rust Setup
In your src-tauri/build.rs:
fn main() {
tauri_plugin_plauth::build();
}
In your src-tauri/src/main.rs:
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_plauth::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
JavaScript/TypeScript Usage
import { authenticate } from "tauri-plugin-plauth-api";
// Basic authentication
try {
const result = await authenticate({
url: "https://example.com/auth",
callback_url_scheme: "myapp://callback",
});
console.log("Authentication successful:", result);
} catch (error) {
console.error("Authentication failed:", error);
}
API Reference
authenticate(request: AuthRequest): Promise<AuthResponse>
Initiates an authentication flow using ASWebAuthenticationSession (iOS) or web view (macOS).
Parameters
url(string): The authentication URL to navigate tocallback_url_scheme(string): The URL scheme to handle the callbackpresentation_context_provider(optional): Custom presentation context provider
Returns
AuthResponse: Object containing the authentication result
Examples
examples/tauri-app/- Example Tauri application demonstrating plugin usage on macOS with React frontend- iOS support is available through the same plugin interface with ASWebAuthenticationSession integration
Code Organization & Structure
Rust Code Structure
src/lib.rs- Main plugin entry point and exportssrc/commands.rs- Tauri command implementationssrc/models.rs- Data structures and typessrc/error.rs- Error handling and custom error typessrc/desktop.rs- macOS-specific implementationssrc/mobile.rs- iOS-specific implementations
Platform-Specific Code
ios/- iOS-specific Swift code with ASWebAuthenticationSessionmacos/- macOS-specific Swift code with ASWebAuthenticationSessionguest-js/- JavaScript/TypeScript client code- Note: Android support is not currently implemented
Known Issues
Authentication Dialog Shows "(null)" During Development
Issue: When running the application in development mode (cargo tauri dev), the authentication dialog may display "(null)" instead of the proper application name.
Cause: This is a known issue with Tauri development mode where the application metadata is not properly loaded.
Solutions:
1. Test with Built Bundle (Recommended)
Build and test the application as a bundle instead of development mode:
cd examples/tauri-app
cargo tauri build
# Test the built .app bundle or .dmg file
2. Check Tauri Configuration
Ensure your tauri.conf.json has the correct productName:
{
"productName": "Your App Name",
"version": "0.1.0",
"identifier": "com.yourcompany.yourapp"
}
3. Add/Update Info.plist
Create or update src-tauri/Info.plist with proper bundle information:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleDisplayName</key>
<string>Your App Name</string>
<key>CFBundleName</key>
<string>Your App Name</string>
</dict>
</plist>
Note: This issue only affects development mode and will not occur in production builds.
Development
Prerequisites
- Rust 1.77.2+
- Tauri 2.7.0+
- Xcode (for iOS and macOS development)
- macOS (for development and testing)
- iOS Simulator or device (for iOS testing)
Building
# Build Rust plugin
cargo build
# Build JavaScript/TypeScript client
yarn build
Testing
# Run Rust tests
cargo test
# Run example app
cd examples/tauri-app
cargo tauri dev
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions, please:
- Check the examples for usage patterns
- Search existing issues
- Create a new issue with detailed information about your problem
Changelog
1.0.0
- Initial release
- macOS and iOS support
- ASWebAuthenticationSession integration
- Basic authentication flow
Dependencies
~16–65MB
~899K SLoC