---
title: "Authentication and Security"
description: "How your app keeps Laravel sessions, CSRF protection, and native access safe on iOS and Android."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.lairport.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication and Security

## 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.

> **Early release**
>
> Lairport is at v0.1. The `laravel-mobile` CLI is published on crates.io, and the `@laravel-rust-mobile/core` adapter is published on npm. Each feature is in beta or alpha: beta features are ready to try on your own apps, and alpha features are experimental. The [status](https://docs.lairport.app/status/) page lists the stage of each feature.

## 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:

```toml title="mobile.toml"
[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.

## OAuth and Deep Links

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:

```toml title="mobile.toml"
[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.

Source: https://docs.lairport.app/auth-and-security/index.mdx
