2021 Safari & WebPrivacy & Security
WWDC21 · 25 min · Safari & Web / Privacy & Security
Move beyond passwords
Despite their prevalence, passwords inherently come with challenges that make them poorly suited to securing someone’s online accounts. Learn more about the challenges passwords pose to modern security and how to move beyond them. Explore the next frontier in account security with secure-by-design, public-key-based credentials that use the Web Authentication standard. Discover in this technology preview how Apple is approaching this standard in iOS 15 and macOS Monterey.
Watch at developer.apple.com ↗Code shown on screen · 3 snippets
Register an account
// Register an account
func createAccount(with challenge: Data, name: String, userID: Data) {
let provider = ASAuthorizationPlatformPublicKeyCredentialProvider(
relyingPartyIdentifier: "example.com")
let registrationRequest = provider.createCredentialRegistrationRequest(
challenge: challenge, name: name, userID: userID)
let controller = ASAuthorizationController(
authorizationRequests: [ registrationRequest ])
controller.delegate = …
controller.presentationContextProvider = …
controller.performRequests()
} Sign in
// Sign in
func signIn(with challenge: Data) {
let provider = ASAuthorizationPlatformPublicKeyCredentialProvider(
relyingPartyIdentifier: "example.com")
let assertionRequest = provider.createCredentialAssertionRequest(challenge: challenge)
let controller = ASAuthorizationController(
authorizationRequests: [ assertionRequest ])
controller.delegate = …
controller.presentationContextProvider = …
controller.performRequests()
} Handle returned credentials
// Handle returned credentials
func authorizationController(controller: ASAuthorizationController,
didCompleteWithAuthorization authorization: ASAuthorization) {
switch authorization.credential {
case let registration as ASAuthorizationPlatformPublicKeyCredentialRegistration:
let attestationObject = registration.rawAttestationObject
let clientDataJSON = registration.rawClientDataJSON
// Verify on your server and finish creating the account.
case let assertion as ASAuthorizationPlatformPublicKeyCredentialAssertion:
let signature = assertion.signature
let clientDataJSON = assertion.rawClientDataJSON
// Verify on your server and finish signing in.
case …:
…
}
} Resources
Related sessions
-
15 min -
8 min