Skip to content

Authentication and Security

How your app keeps Laravel sessions, CSRF protection, and native access safe on iOS and Android.

Introduction

Your app is simply another browser for your Laravel Rust server. It loads your pages over HTTPS, so your session authentication and CSRF protection keep working without any changes. This page covers the few things that are different on a phone.

Allowed Hosts

Your server.url must use https, unless it points to localhost. Pages on that host stay inside your app, and so do pages on the hosts in allowed_hosts. If your sign-in flow visits another host, such as an OAuth provider, you may keep it inside your app by adding it to the allowed_hosts option:

mobile.tomltoml
[server]
url = "https://acme.com"
allowed_hosts = ["auth.acme.com"]

Every other http or https link opens in the system browser, including a link that a server redirect sends to another host, and an Inertia redirect to an external URL. Links with other schemes open in their apps, so mailto: opens the mail app and tel: opens the phone app. A wildcard such as "*.acme.com" matches subdomains only, so it doesn’t match acme.com itself. List both if you need both.

On iOS, a page can embed content from other hosts in an iframe, such as a payment form or a video. The app can’t tell an iframe from the page, so every host that your pages embed must be in allowed_hosts, or the embedded content opens in the browser. For example, "*.stripe.com" or "www.youtube.com".

Native Access From Remote Pages

By default, Tauri v2 doesn’t let remote pages call native code. The sync command writes capabilities/mobile.json from your mobile.toml file, and milestone M4 will limit native access to exactly the hosts you list.

Sessions and Cookies

On Android, the app saves the WebView’s cookies when it pauses, so a fresh login survives the app being killed right after. On iOS, WKWebView can lose cookies when your app restarts, which would sign your users out. Milestone M4 adds persistent session cookies on iOS, tested on physical devices.

When a sign-in flow leaves your app, it returns through a deep link. To enable deep links, add a custom scheme or the hosts of your universal links to the deep_links section of your mobile.toml file. The deep-link plugin is enabled for you automatically:

mobile.tomltoml
[deep_links]
schemes = ["acme"]
hosts = ["acme.com"]

A link opens on the matching page of your app’s server, keeping its query and fragment. acme://receipts/42, acme:///receipts/42 and https://acme.com/receipts/42 all open /receipts/42. Under dev, that page loads from the dev server on your machine. To send an OAuth provider’s callback back to the app, point it at acme://oauth/callback, or at a path on one of your app-link hosts. A link that launches a closed app waits until the first page loads, so the sign-in completes even on a cold start.

We confirmed this round trip on a phone: the sign-in page opened, and the callback returned the user to the app, signed in.

sync doesn’t write the app link intent filters into apps/mobile/gen/AndroidManifest.xml. Tauri adds them when it builds the app, so if they’re missing from that file after sync, that’s expected.

Type to search…

↑↓ navigate↵ selectEsc close