Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Passkeys Sample accompanying the Passwordless blogpost #225

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"pins" : [
{
"identity" : "appauth-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/openid/AppAuth-iOS.git",
"state" : {
"revision" : "33660c271c961f8ce1084cc13f2ea8195e864f7d",
"version" : "1.5.0"
}
},
{
"identity" : "facebook-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/facebook/facebook-ios-sdk.git",
"state" : {
"revision" : "5c7367dadcbe504702c041621dc09752bf2cd747",
"version" : "16.0.1"
}
},
{
"identity" : "forgerock-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ForgeRock/forgerock-ios-sdk.git",
"state" : {
"revision" : "d78e9f26be17df12476198a4fae1ef532432ab8b",
"version" : "4.0.0"
}
},
{
"identity" : "googlesignin-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleSignIn-iOS.git",
"state" : {
"revision" : "7932d33686c1dc4d7df7a919aae47361d1cdfda4",
"version" : "7.0.0"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "4e9bbf2808b8fee444e84a48f5f3c12641987d3e",
"version" : "1.7.2"
}
},
{
"identity" : "gtmappauth",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GTMAppAuth.git",
"state" : {
"revision" : "b9d1683be336ba8c8d1c6867bafeb056a5399700",
"version" : "1.3.0"
}
},
{
"identity" : "jgprogresshud",
"kind" : "remoteSourceControl",
"location" : "https://github.com/JonasGessner/JGProgressHUD.git",
"state" : {
"revision" : "78d7cd35f1d90ff74fd82e486f2cbe4b24be8cf9",
"version" : "2.2.0"
}
},
{
"identity" : "joseswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airsidemobile/JOSESwift.git",
"state" : {
"revision" : "10ed3b6736def7c26eb87135466b1cb46ea7e37f",
"version" : "2.4.0"
}
}
],
"version" : 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// AppDelegate.swift
// BioExample
//
// Created by George Bafaloukas on 07/07/2021.
//

// Swift
//
// AppDelegate.swift
import UIKit
import FRAuth

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {

return true
}

// This method is one of AppDelegate protocol that is invoked when iOS tries to open the app using the app's dedicated URL
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

let resumeURL = url // validate the resumeURI contains 'suspendedId' parameter

// With given resumeURI, use FRSession to resume authenticate flow
FRSession.authenticate(resumeURI: resumeURL) { (token: Token?, node, error) in
// Handle Node, or the result of continuing the the authentication flow
}

return true
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "pebble-logo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// AuthenticatedViewController.swift
// UnsummitAuthentication
//
// Created by George Bafaloukas on 10/05/2022.
//

import UIKit
import FRAuth
import JGProgressHUD

class AuthenticatedViewController: UIViewController {

@IBOutlet weak var pebbleLogo: UIImageView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var infoTextView: UITextView!
@IBOutlet weak var logoutButton: UIButton!

private var infoText: String = ""
private let hud = JGProgressHUD()

override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.setHidesBackButton(true, animated: false)
self.updateStatus()
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
self.pebbleLogo.addGestureRecognizer(tap)
self.infoTextView.alpha = 0.0
view.addGestureRecognizer(tap)
}

@objc func handleTap() {
UIView.animate(withDuration: 1.0, delay: 0.1, options: [], animations: {
self.infoTextView.alpha = 1.0
self.pebbleLogo.alpha = 0.0
}, completion: nil)
}

@IBAction func SettingsAction(_ sender: Any) {
self.performSegue(withIdentifier: "OpenSettings", sender: self)
}

// MARK: - Private Methods

private func updateStatus() {
if let user = FRUser.currentUser {
self.hud.textLabel.text = "Loading user info"
self.hud.show(in: self.view)
// Call the User Info endpoint and parse the results
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
user.getUserInfo { userInfoObject, error in
if let userInfoObject = userInfoObject {
self.infoText = "User is authenticated \n \n \n"
self.infoText = self.infoText + (userInfoObject.userInfo.debugDescription) + "\n \n"
self.infoText = self.infoText + (user.token?.debugDescription ?? "") + "\n \n"
self.updateText(userInfoObject)
} else {
self.logOutAndDismiss()
}
}
}

}
}

private func updateText(_ userInfoObject: UserInfo) {
DispatchQueue.main.async {
self.nameLabel.text = "Welcome \(userInfoObject.name ?? "")"
self.infoTextView.text = self.infoText
self.hud.dismiss()
}
}

private func logOutAndDismiss() {
self.hud.textLabel.text = "Loging out"
self.hud.show(in: self.view)
FRUser.currentUser?.logout()
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.hud.dismiss(animated: true)
self.navigationController?.popViewController(animated: true)
}
}

@IBAction func logoutAction(_ sender: Any) {
// Call Logout and navigate back
self.logOutAndDismiss()
}

}
Loading