PWA Lock

FIXES

Why a website login may fail inside a web-app wrapper

A site's login loops or sends you elsewhere behind PWA Lock? What a wrapper changes, which sign-in designs break, what to try, and what cannot be fixed.

A person walking away from a phone that shows an access-denied cross

Most websites sign in normally behind PWA Lock. The ones that fail almost always do one of two things during login: they send your browser to another address partway through, such as a sign-in provider or a different subdomain of the same site, or they check which address they are being served from and stop when it is not their own. Neither is a bug in the site or in the lock; it is how the site was built, which decides whether there is a workaround. We make PWA Lock, so it is the example here, but the same mechanics apply to any wrapper that fetches pages through its own servers.

What does a wrapper change about a website?

When you open a locked app, your browser talks only to the locked address, such as my-notes.pwalock.com. PWA Lock's servers fetch each page from the original site and return it under that address, doing a few specific things on the way:

  • Links and requests that spell out the original address are rewritten to relative ones, so following them keeps you inside the lock. Only the domain you entered when creating the app is rewritten; any other subdomain or domain is left alone.
  • Redirects back to the original site are made relative too. A redirect anywhere else is handed to your browser unchanged, and the browser follows it out of the lock.
  • The site's own cookies pass through in both directions. A cookie the site sets is stored for the locked address (PWA Lock removes the Domain attribute, which would name the original site and make the browser refuse it) and is sent back on later requests. PWA Lock's own cookies, such as your account login and the unlock, are never forwarded to the site.
  • A small block is added to the top of each page: the icon and manifest that make the locked address installable, and a script that relocks the app when you switch away. Otherwise the page passes through as the site sent it.

Three things look different to the site. The Origin and Referer headers your browser sends name the locked address, and PWA Lock forwards them as they arrive. The site's own scripts see the locked address when they look at the current hostname. And requests arrive from PWA Lock's servers, not your phone. Everything else is as usual: its own hostname in the Host header, the path, your form entries, and every cookie it set through the lock. All of it passes through PWA Lock's servers in memory and is not intentionally stored; What PWA Lock protects, and what it does not spells out that boundary.

Which login designs fail, and why?

What you seeWhat is happeningCan you fix it?
Sign in with Google, Apple or another provider leaves you signed in on the original site, in Safari, outside the lockThe site sends your browser to the provider, which returns you to the address the site registered: the original site.Not on this path. Use the site's email and password login if it has one.
You sign in and are asked to sign in again, or see an error such as invalid request or origin mismatchThe site's login runs on another subdomain and sets its cookie there, out of the locked address's reach; or the site rejected the form because the Origin header named the locked address.Sometimes, by creating the app with the subdomain the app really uses. Not for Origin checks.
The sign-in button spins or does nothingThe site's scripts call an API on another domain directly from your browser. From the locked address that is a cross-origin request the API has not allowed, with cookies Safari treats as third-party and blocks.No.
After signing in you land on the site's www or app subdomain in SafariThe site redirected to a domain other than the one you entered, and only redirects to that exact domain stay inside the lock.Yes. Create the app again with the address you end up on.
A passkey or security key is not offered, or failsPasskeys are bound to the site's own domain, not to the locked address.No. Use the password login.
The page stays blank after the lockThe site's Content-Security-Policy header forbids inline scripts. PWA Lock passes that header through, so its own small script is blocked and the page can stay hidden.No.
The website address is refused when you create the appIt starts with http://, uses a port other than 443, includes a username, password or fragment, or is an IP address or a private name. Only public HTTPS sites are proxied.Use the site's https:// address if it has one. An HTTP-only site cannot be locked.

Why does a sign-in provider take you out of the lock?

Sign in with Google, Apple and most other log in with buttons use OAuth 2.0 or a protocol built on it. RFC 6749 gives the flow a fixed shape: the site sends your browser to the provider, you approve there, and the provider sends your browser back to a return address the site registered in advance, refusing any other. That refusal protects your account with the site; it is a feature, not a quirk.

Through the lock, the very first step leaves. The redirect to the provider is not a redirect to the site, so PWA Lock hands it to your browser untouched, and the return trip goes to the registered address, the original site, where you arrive signed in while the locked address knows nothing about it. PWA Lock cannot add itself to the site's registration.

What can you try?

  1. Use the site's email and password login. Most sites with social sign-in also offer one. That form posts to the site itself, the cookie it sets in reply is stored for the locked address, and every later page carries it. If social sign-in is the only option, the site will not work behind the lock.
  2. Check the address you gave PWA Lock. Sign in to the site in Safari and look at the address you end up on. If it is not exactly the one you entered when creating the app, the lock guards the wrong door. Apps cannot be edited yet, so create a new app with that address, following the setup guide, and ask contact@pwalock.com to remove the old one, which counts toward your plan's app limit until then. That Safari login stays in Safari: cookies are kept per address, and PWA Lock forwards only what your browser sends to the locked one.
  3. Point an email sign-in link at the lock by hand. Such a link names the original site, so tapping it opens the site in Safari, outside the lock. Instead, copy it, replace the site's domain with your locked address, keep the rest, and open it while the app is unlocked. PWA Lock fetches the same path from the site, and the cookie set in reply is stored for the locked address. This works only when the link names the domain you entered when creating the app.
  4. Try Safari and the installed app separately. iOS gives an installed web app its own cookies and storage, separate from Safari, so a login in one does not show up in the other. Being asked again in the home-screen app is a second sign-in, not a compatibility problem; Home-screen web app vs Safari tab explains the split.
  5. Write to support with the two addresses. Send the locked address, the website address you entered and what you saw to contact@pwalock.com, never a password, for the site or for PWA Lock. A wrong address or a moved login is something we can point out; a provider that returns only to the address it was given is not.

What PWA Lock does not do about it

The limits, stated plainly:

  • It does not rewrite the site's JavaScript beyond replacing the exact original address, so a script that compares hostnames or calls another subdomain keeps doing so, and it does not complete a sign-in flow on its servers while acting as you.
  • It does not remove the site's security headers, so a strict Content-Security-Policy can block PWA Lock's own script. A page that loads without it will not relock when you switch away; the unlock still expires after 15 minutes, because the server enforces that limit.
  • It does not replace the site's own login or restrict the original address, which stays reachable for anyone who has its login; PWA Lock is a gate on the locked address only.

If your site lands in the rows marked No, PWA Lock is not the right tool for it, and we would rather say so. Can you password-protect a website on your iPhone? compares the other routes to a password in front of one site, including Apple's built-in options.

Frequently asked questions

Does PWA Lock see the password I type into the site's login form?

Like everything you do inside a locked app, the form travels through PWA Lock's servers on its way to the site, where it is handled in memory and not intentionally stored. It is separate from PWA Lock's own passwords for your account and for each app, which are stored as salted hashes. What PWA Lock protects, and what it does not lists exactly what is kept.

Can I use Sign in with Apple or Google behind PWA Lock at all?

Not as the way into the locked app. The provider returns you to the address the site registered, which is the original site, so you end up signed in there rather than at the locked address. If the site also offers an email and password login, use that inside the lock. If social sign-in is its only option, that site cannot be locked with PWA Lock.

The login works in Safari at the locked address but the home-screen app asks again. Is that a bug?

No. iOS gives an installed web app its own cookies and storage, separate from Safari, so the site's login has to be done once more inside the installed app, and the first launch may ask for your PWA Lock account login too. After that the site remembers you there the same way it does in Safari.

Does a failed login through the lock put my account with the site at risk?

Not by itself. The site received an ordinary login attempt and either declined it or completed it at its own address; the unusual part was only where the request came from. A site that notifies you about sign-ins from a new location may send its usual notice, because the request reached it from PWA Lock's servers rather than from your phone. PWA Lock changes nothing about your account with the site.

Could the site's owner make its login work behind a wrapper?

Only they could, and it would take changes on their side: registering the locked address with their sign-in provider, allowing it in their cross-origin rules, or dropping the checks that reject it. Almost no site does this for a wrapper it does not run, and PWA Lock cannot do it for them. Treat a site that fails for these reasons as one PWA Lock does not support.

If my site turns out not to work, do I pay anything?

Not if you cancel before the trial ends. Every plan starts with a 14-day free trial run by Creem, our payment partner: your card is saved at checkout and first charged when the trial ends, and cancelling before then costs nothing. The app you created still counts toward your plan's app limit, because apps cannot be deleted from the dashboard yet; write to contact@pwalock.com to have it removed.

Sources

  1. MDN: Redirections in HTTP
  2. RFC 6749: The OAuth 2.0 Authorization Framework (redirection endpoint)
  3. MDN: Using HTTP cookies
  4. WebKit: Full third-party cookie blocking and more
  5. MDN: Same-origin policy

TRY IT WITH YOUR OWN APP

Try it first with a site that has a plain login.

Every plan starts with a 14-day free trial, and Starter covers 2 apps, enough to find out whether your site cooperates. Your card is saved at checkout and first charged when the trial ends; cancel before then and you pay nothing.

14 days free on every plan. Then Starter is $4 a month billed yearly ($48 a year), or $5 a month, for 2 locked apps. Your card is saved at checkout and first charged when the trial ends; cancel before then and you pay nothing.