| Crates.io | tauri-plugin-plauth |
| lib.rs | tauri-plugin-plauth |
| version | 1.0.4 |
| created_at | 2025-08-15 03:35:05.171161+00 |
| updated_at | 2025-09-24 09:52:52.695759+00 |
| description | Tauri plugin for authentication (PLAUTH) supporting macOS and iOS platforms with ASWebAuthenticationSession |
| homepage | https://github.com/lecaobaophuc0912/tauri-plugin-plauth |
| repository | https://github.com/lecaobaophuc0912/tauri-plugin-plauth |
| max_upload_size | |
| id | 1796158 |
| size | 186,860 |
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 | 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 |
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
npm install tauri-plugin-plauth-api
# or
yarn add tauri-plugin-plauth-api
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");
}
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);
}
authenticate(request: AuthRequest): Promise<AuthResponse>Initiates an authentication flow using ASWebAuthenticationSession (iOS) or web view (macOS).
url (string): The authentication URL to navigate tocallback_url_scheme (string): The URL scheme to handle the callbackpresentation_context_provider (optional): Custom presentation context providerAuthResponse: Object containing the authentication resultexamples/tauri-app/ - Example Tauri application demonstrating plugin usage on macOS with React frontendsrc/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 implementationsios/ - iOS-specific Swift code with ASWebAuthenticationSessionmacos/ - macOS-specific Swift code with ASWebAuthenticationSessionguest-js/ - JavaScript/TypeScript client codeIssue: 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:
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
Ensure your tauri.conf.json has the correct productName:
{
"productName": "Your App Name",
"version": "0.1.0",
"identifier": "com.yourcompany.yourapp"
}
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.
# Build Rust plugin
cargo build
# Build JavaScript/TypeScript client
yarn build
# Run Rust tests
cargo test
# Run 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: