Sign in with apple: a zero code approach
Image from https://www.macobserver.com/
Apple announced a lot of cool things during its worldwide developer conference last week. Amidst “ingenious” innovations like the $999 monitor stand, there was one particular announcement that caught my eye. The introduction of the Sign In with Apple feature.
In a nutshell Sign In with Apple
- Provides an API for developers to build a login functionality
- Allows users with Apple IDs to use their existing account to sign into third-party apps
- Controls the information shared at login
At a glance, this seems like just any other federated login option such as Login with Google, Facebook or any other identity provider. But Apple claims there’s more. According to the keynote, when a user logs in using Sign In with Apple, they can choose either to share their real email or a randomly generated email address unique to each app. These randomly generated email addresses will act as a proxy between the app and the user.
The Authorization Flow
Behind the scenes, Sign In with Apple uses the Open ID Connect (OIDC) Authorization code flow. As OIDC is a standard, implementing the login is going to be a lot easier (because of the availability of a lot of client libraries, etc.).
It's a simple two-step process to complete the login:
- Redirect the user to Apple’s authorize endpoint (think of it as the login initiation endpoint). Apple takes care of authenticating the user and sends your app a “code”.
- Your app exchanges the “code” to a token containing the logged in user’s information.
(You can learn more about the authorization code flow here.)
What about sign out?
Well, sign in happens fine.
But how do we sign out of the session? Does Sign In with Apple create a session at all?
Logging in with the Sign In with Apple option does not create a session in the browser at the moment (at least from what I have found so far).
Which means if you send two authorization requests to Apple from the same browser one after the other, you will have to login again.
When I entered my username at the login page, I noticed that a request is sent as shown below, which validated my account. The “isRememberMeEnabled=false” could be the reason for not maintaining a session.
https://appleid.apple.com/appleauth/auth/federate?isRememberMeEnabled=f…

So every time your application sends you to log in, you will have to authenticate by going through the two steps. Therefore it is your app that will have to maintain a session and log the users out of the session.
So as for now, you don’t have to worry about the sign out part.
What does this mean to you?
- If you are an app developer, chances are that as soon as this feature gets commercial support you would have to start supporting it as a login option for your users.
- Since Apple enforces multi-factor authentication and allows users to shield their private information from third-party apps, Sign In with Apple could become the defacto login mechanism for nearly 1.4 billion Apple ID accounts.
- From a developers perspective, this means your app would need some refactoring/modification in order to support the Sign In with Apple option.

- If your app already supports OIDS, then you would have less hassle in supporting this. But it would still require some code changes to deal with providing multiple options for login and every time a “Sign with X” (X is an IDP just like Apple or Google) comes in.

So do we have other options to consider?
Zero Code Change Support for Sign In with Apple
Let’s take a look at how to support “Sign with Apple” or any other “Sign in with X” option in a scalable manner.
In this solution, we will be using an identity and access management (IAM) provider to do the “Sign with Apple” part for us. Your app will only be talking to the IAM provider. This essentially means we will be introducing a layer between your app and external identity providers.
WSO2 Identity Server will be used as an example in this solution.

Step 1: Make your app speak in a standard protocol
Connect your app to the IAM provider via a standard protocol. Most IAM providers support protocols such as OIDC, Security Assertion Markup Language (SAML), and Central Authentication Service (CAS). If your app already speaks in any of these protocols you have less to do.
If not then you can follow the steps explained here to achieve it without a code change. There are filters and other mechanisms you can follow to make your app communicate in a standard protocol with an IAM provider without actually modifying the code much.

So basically this means your app now knows to talk to an identity provider in a standard protocol.
Step 2: Make your IAM provider do the “Sign In with Apple”
If your IAM provider supports standard OIDC federation, chances are that this is pretty easy to do. Typically this would involve three steps:
- Configure your IAM provider (in my example WSO2 Identity Server) as a trusted entity in Apple. Once you register, you will get a client_id and client_secret from Apple and also register WSO2 Identity Server’s callback URI at Apple.
- Configure the obtained details in the first step and add Apple as a trusted identity provider in your IAM provider.
- Engage the configured identity provider (Apple) during your app’s authentication flow.
A detailed post on how we actually do this can be found here.
What’s next: Support another “Sign in with X”
Let’s say you wanted to support sign in with Google for the same app. No problem! As you can see this is where the introduced IAM layer comes into play.
It’s just a matter of following Step 2 for Google instead of Apple. And you don’t even need to worry about touching the app.

WSO2 Identity Server, as well as most IAM providers, provide other capabilities such as attribute transformation and engaging rules in the authentication flow. So having an IAM layer to communicate with the external identity providers helps you keep your app logic clean and free of authentication/authorization login that tends to change dynamically.
To learn more register for our webinar on Apple Sign In: A Zero-Code Integration Approach Using WSO2 Identity Server.





