Improve compatibility with iCloud Keychain
-
Apple has suggested a scheme for adding TOTP secrets to password managers with a simple click. The solution currently works with Apple’s own password manager iCloud Keychain in Safari on iOS 15, iPad OS 15 and macOS Monterey.
More info: https://developer.apple.com/videos/play/wwdc2021/10105I wrote a simple proof-of-concept by adding a method called get_totp_link_ref to the WizardSteps class.
** * Get TOTP link reference (preview) * * Returns a TOTP link reference. For use with the iCloud Keychain and * other compatible password managers. * * * @return String */ public static function get_totp_link_ref() { // Get URL encoded site name and domain $site_name = urlencode( get_bloginfo( 'name', 'display' ) ); $site_url = get_site_url(); $site_domain = parse_url( $site_url )['host']; // Get user's username and secrect $user_username = wp_get_current_user()->user_login; $user_secret = self::getUser()->get_totp_decrypted(); // Create TOTP link target $totp_link = 'otpauth://totp/' . '$site_name' . ':' . $user_username . '?secret=' . $user_secret . '&digits=6&time=30&issuer=' . $site_domain; // Return escaped URL return esc_url( $totp_link, array( 'otpauth' ) ); }
The method returns a string that can be as a reference for a dedicated link or a clickable version of the QR code.
<div class="qr-code-wrapper"> <a href="<?php echo esc_html( self::get_totp_link_ref() ); ?>"> <?php echo $qrCode; ?> </a> <div>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Improve compatibility with iCloud Keychain’ is closed to new replies.