15.4 C
New York
Tuesday, September 9, 2025

The evolution of Put on OS authentication



The evolution of Put on OS authentication

Posted by John Zoeller – Developer Relations Engineer

This submit is a part of Put on OS Highlight Week. In the present day, we’re specializing in implementing Credential Supervisor on Put on OS, aiming to streamline the authentication expertise.

For all software program builders, crafting a quick and safe authentication move is paramount, and that is equally vital on Put on OS.

The normal Put on OS strategies require customers to have their telephone close by to finish authentication, usually with a separate cellular move or 2-factor auth code.

Credential Supervisor‘s arrival simplifies this course of, permitting for authentication straight from a person’s watch without having for a close-by telephone.

As a unified API, Credential Supervisor lets you reuse your cellular app’s code on Put on OS, streamlining growth throughout kind elements. With a single faucet, customers can authenticate with passwords, federated identities like Check in with Google, or passkeys, the brand new trade customary for safety.

Credential Manager on a wearable device providing the security of passkey authentication

Credential Supervisor offers the safety of passkey authentication with a single faucet

The ability of passkeys

Passkeys are constructed on the precept of uneven encryption. Throughout creation, a system authenticator generates a singular, mathematically linked pair of keys: a public key that’s securely saved on-line with the service, and a non-public key that continues to be completely on the person’s gadget.

When signing in, the gadget makes use of the personal key to cryptographically show to the service that it possesses the important thing.

This course of is extremely safe as a result of the personal key by no means leaves the gadget throughout authorization (solely throughout syncs from credential suppliers) and might solely be used with the person’s express permission. This makes passkeys proof against server breaches, as a breach may solely ever expose the general public half of the important thing pair. Moreover, since there isn’t any passphrase to steal, passkeys are nearly phishing-proof.

The person expertise of passkeys is seamless: to log in, a person confirms their presence with their gadget’s lock (e.g., biometric credential or PIN), and they’re signed in. This eliminates the necessity to keep in mind advanced passphrases and offers a sooner, safer methodology of authentication that works seamlessly throughout gadgets.

flow chart illustrating movement of secured information between the user's device and the app server

Passkeys are cryptographically linked, and accessed securely from person gadgets

Designing authentication with Credential Supervisor

Credential Supervisor needs to be the bottom of a Put on app’s authentication move. Builders ought to resolve which of its built-in strategies to implement based mostly on what’s applied of their cellular experiences, and based mostly on the number of authentication strategies their customers want.

Passkeys are the popular built-in resolution because of their inherent safety and ease, however the different built-in choices Credential Supervisor offers can be applied. Passwords are helpful due to their familiarity to customers, and federated identities like Check in with Google present customers with the consolation of a trusted supplier.

Credential Manager on a wearable device providing the security of passkeys, passwords, and sign in with google

Passkeys, passwords, and sign up with google might be offered by Credential Supervisor

Builders ought to preserve at the very least one in all their current authentication choices as a backup as they transition their customers to Credential Supervisor. If Credential Supervisor is dismissed by a person, or if all of its strategies fail, or if credentials are usually not out there, builders can current their backup choices.

The Put on Authentication developer information consists of particulars on supported Put on OS backup authentication choices. These embrace options like OAuth 2.0, which has historically been a well-liked alternative on Put on OS; and information layer token sharing, which can be utilized to routinely authenticate customers at app launch time if their telephone is close by to sync a signed in account.

Learn the complete Put on sign-in design steerage to find out about all the very best practices for designing your authentication move, together with our particular steerage round information layer token sharing.

authentication flow on the left with dismiss highlighted, and sign in flow on the right

Tapping dismiss ought to carry up your backup authentication strategies

Implementing Credential Supervisor on Put on OS

Primary GetCredential setup

At its core, Credential Supervisor consolidates a number of authentication strategies right into a single, unified API name: getCredential. By configuring a GetCredentialRequest together with your authentication choices, you should utilize the response to validate a person’s identification together with your app’s server that comprises the credentials, like so:

val request = GetCredentialRequest(getCredentialOptions())
val getCredentialResponse = credentialManager.getCredential(exercise, request)

login(getCredentialResponse.credential)

Sync Credentials with Digital Asset Hyperlinks

For a very seamless expertise, a person’s credentials should sync effortlessly from their different gadgets to their watch, since it’s at the moment not doable to create credentials on Put on OS.

To allow this, it’s essential to add an entry for Put on OS in your Digital Asset Hyperlinks to affiliate your Put on OS app with different variations of your app. Remember to exactly fill out the asset hyperlink entry, together with your app’s applicationId and the SHA-256 cryptographic hash out of your utility’s digital signature. You’ll be able to take a look at them out with our app hyperlink verification information.

Furnishing getCredential with built-in credentials

To permit customers to sign up with Credential Supervisor, present getCredential with choices for the three built-in authentication sorts: passkeys, passwords, and federated identities like Check in With Google.

// Including choices is a part of creating the credential request
GetCredentialRequest(getCredentialOptions()))

// Furnish checklist of CredentialOptions for the request
droop enjoyable getCredentialOptions(): Record<CredentialOption> {
  return listOf(
    // Passkey: Furnish a GetPublicKeyCredentialOption with public key
    // information out of your authentication server
    GetPublicKeyCredentialOption(authServer.getPublicKeyRequestOptions()),
    // Password: Add the offered GetPasswordOption sort in your checklist
    GetPasswordOption(),
    // Federated Id: Add your required choice sort (GetGoogleIdOption, under)
    // to orchestrate a token alternate with the federated identification server.
    GetGoogleIdOption.Builder().setServerClientId(SERVER_CLIENT_ID).construct(),
  )
}

When getCredential is named, Credential Supervisor will use the choices builders present to current customers with a UI to decide on how they need to log in.

Credential Selection screen display on a wearable device

The Credential Choice Display screen shows developer-provided choices

Dealing with built-in Credential sorts

After a person selects their desired credential within the Credential Supervisor UI, use the results of getCredential (which comprises the chosen credential) to path to your authentication handlers.

// getCredential returns the chosen credential
login(getCredentialResponse.credential)

// Path to your credential dealing with features to login
droop enjoyable login(credential: Credential): LoginResult {
  when (credential) {
    is PublicKeyCredential -> {
      return authHandler.loginWithPasskey(credential.authenticationResponseJson)
    }
    is PasswordCredential -> {
      return authHandler.loginWithPassword(credential.id, credential.password)
    }
    is CustomCredential -> {
      return authHandler.loginWithCustomCredential(
          credential.sort, credential.information)
    }
    // ‘else’ case, and so on…

The dealing with logic for every of the above loginWith’x’ strategies is barely totally different, though all of them arrange community calls to devoted authentication endpoints. Beneath are simplified variations of those strategies which show community calls to authenticate customers based mostly on their chosen methodology.

Passkeys require the signed passkey JSON information. Your server will use this information to cryptographically confirm the person.

droop enjoyable loginWithPasskey(passkeyResponseJSON: String): LoginResult {
  val validatedPasskey = httpClient.submit(
      "myendpoint/passkey", passkeyResponseJSON, /*different args*/)

  return LoginResult(validatedPasskey)
}

Passwords require community logic to validate the username and password, our instance makes use of subsequent calls to validate the username first. Your backend will validate these towards its person database.

droop enjoyable loginWithPassword(userName: String, password: String): LoginResult {
  val validatedUserName = httpClient.submit(
      "myendpoint/username", userName, /*different args*/)
  val validatedPassword = httpClient.submit(
      "myendpoint/password", password, validatedUserName, /*different args*/)

  return LoginResult(ValidatedPassword)
}

Federated identities like Check in with Google require {that a} safe connection is established between your server and your app. Our pattern reveals a challenge-response move initiated from the server, however a consumer generated nonce works as nicely.

Our pattern server offers a problem to our app on request (federatedSessionId, under) which is subsequently used to validate the federated token to authenticate the person.

droop enjoyable loginWithCustomCredential(sort: String, information: Bundle): LoginResult {
  if (sort == GoogleIdTokenCredential.TYPE_GOOGLE_ID_TOKEN_CREDENTIAL) {
    token = GoogleIdTokenCredential.createFrom(information).idToken
  }

  // Set up a federated session for together with your server and procure its data
  val federatedSessionId = httpClient.submit("myendpoint/ObtainFederatedSession",
      /*federated backend tackle=*/"https://accounts.google.com")

  // Validate the token with the established federated session.
  val validatedCustomCredential = httpClient.submit(
      "myendpoint/verifyToken", token, federatedSessionID,
      /*federated backend tackle=*/"https://accounts.google.com")

  return LoginResult(validatedCustomCredential)
}

Dealing with secondary Credential sorts

If a person faucets dismiss, or swipes again from Credential Supervisor, a GetCredentialCancellationException can be thrown for builders to make use of to navigate to their backup login screens, which is able to present secondary authentication choices to customers. These choices are detailed within the Designing Authentication with Credential Supervisor part, above.

// Catch the person dismissal
catch (e: GetCredentialCancellationException) {
  // Set off occasion that navigates to ‘BackupLoginScreen’
  uiEvents.ship(UiEvent.NavigateToBackupLogin)
}

Particular Observe: The model of Google Check in that exists outdoors of Credential Supervisor is now deprecated and can be eliminated, and shouldn’t be offered as a secondary choice to keep away from presenting two buttons for a similar objective.

See the Put on OS transition information for extra particulars.

Get began with Credential Supervisor on Put on OS

Implementing Credential Supervisor on Put on OS is a simple course of that delivers important advantages. By adopting this API, you possibly can present your customers with a safe, seamless, and environment friendly approach to authenticate. To start implementation, discover our developer documentation and official pattern app.

To find out how apps have migrated to Credential Supervisor on Put on OS, take a look at our case research with Todoist, who have been in a position to streamline their authentication while reusing their cellular implementation.

For a have a look at how passkeys can enhance login success fee, you possibly can learn all about how X adopted passkeys to realize a safer and user-friendly authentication expertise.

Lastly, you possibly can watch the brand new credential supervisor video weblog on YouTube to bolster all the things you’ve discovered right here.

Glad coding!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

0FansLike
0FollowersFollow
0SubscribersSubscribe
- Advertisement -spot_img

Latest Articles