We have an OpenID Connect Provider authentication application implemented with Vaadin 8.5.1. A part of what it does is redirect the user back to the relying party’s return URL. That URL might be for a mobile app, which has registered a custom scheme, such as myapp://callback
.
Redirecting to a custom scheme works fine on Android with Chrome using any of the techniques we’ve tried. An Android app will open correctly.
But redirecting on Safari on an iPhone to an iOS app seems to fail every time.
We’ve tried every kind of redirect technique we could think of, even chaining multiple redirects together. It seems like Safari blocks the redirect if it was initiated from a Vaadin app. The only way to get the mobile app to open is to create a clickable link and have the user click it manually. This of course isn’t acceptable, since the final URL is dynamically generated after the user has authenticated.
Some of the techniques we’ve tried:
Page.getCurrent().open(url, null);
Page.getCurrent().open(url, "_blank");
Page.getCurrent().setLocation(url);
- setLocation() to a servlet that responds with status 302 and location header: (HttpServlet.sendRedirect)
- setLocation() to a servlet which generates a page with a Javascript redirect script:
<script type="text/javascript">setTimeout("location.href = '%s';",5000);
- setLocation() to a servlet which generates a page with meta-refresh element in the head
- setLocation() to a servlet which generates a page with a clickable link, and javascript which clicks the link after a delay
- setLocation() to a completely external page that redirects with a 302 response
The Safari browser just doesn’t do anything when it comes time to open the mobile app.
If we try to run the servlet manually (not from the Vaadin app, but entering the servlet URL directly to the browser) then the redirects work correctly in Safari and the app opens.
If we redirect to any normal HTTP/HTTPS URL, the redirect works on Safari correctly. The issue is therefore only with custom URL schemes.
The code to our Vaadin test app: https://pastebin.com/HJcCEFQj and to the servlet: https://pastebin.com/U6SLyWvV
Has anyone here tried something like this?