Tauri plugin for authentication (PLAUTH) supporting macOS and iOS platforms with ASWebAuthenticationSession
npm install tauri-plugin-plauth-apiA Tauri plugin for authentication (PLAUTH) that currently supports macOS and iOS platforms only. The plugin implements ASWebAuthenticationSession for secure web-based authentication flows.



| 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 |
- 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
Add the following to your Cargo.toml:
``toml`
[dependencies]
tauri-plugin-plauth = "1.0.0"
Or use the cargo add command:
`bash`
cargo add tauri-plugin-plauth
`bash`
npm install tauri-plugin-plauth-apior
yarn add tauri-plugin-plauth-api
In your src-tauri/build.rs:
`rust`
fn main() {
tauri_plugin_plauth::build();
}
In your src-tauri/src/main.rs:
`rust`
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_plauth::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
`typescript
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);
}
`
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/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
- 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
- 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
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:
`bash`
cd examples/tauri-app
cargo tauri buildTest the built .app bundle or .dmg file
#### 2. Check Tauri Configuration
Ensure your tauri.conf.json has the correct productName:
`json`
{
"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`
Note: This issue only affects development mode and will not occur in production builds.
- 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)
`bashBuild Rust plugin
cargo build
$3
`bash
Run Rust tests
cargo testRun example app
cd examples/tauri-app
cargo tauri dev
``Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
1. Check the examples for usage patterns
2. Search existing issues
3. Create a new issue with detailed information about your problem
- Initial release
- macOS and iOS support
- ASWebAuthenticationSession integration
- Basic authentication flow