I want to implement Single Sign On Extension for an iOS 13 app. I've already gone through various blogs, but there seems to be no standard solution available for implementing single sign-on extensions.
I'm trying to build up my own SSO solution, but I've not yet been able to implement it successfully. Here is the code that I have written so far:
import UIKit
import AuthenticationServices
class ViewController: UIViewController {
@IBOutlet weak var loginButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func loginButtonPushed(_ sender: Any) {
let issuer = URL(fileURLWithPath: "https://url_here")
let ssoProvider = ASAuthorizationSingleSignOnProvider(identityProvider: issuer)
let request = ssoProvider.createRequest()
request.requestedScopes = [.fullName, .email]
request.authorizationOptions = [
URLQueryItem(name: "client_id", value: "client_id"),
URLQueryItem(name: "response_type", value: "code")
]
let authzController = ASAuthorizationController(authorizationRequests: [request])
authzController.delegate = self
authzController.presentationContextProvider = self
authzController.performRequests()
}
}
extension ViewController: ASAuthorizationControllerDelegate {
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
}
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
// Handle error.
}
}
extension ViewController: ASAuthorizationControllerPresentationContextProviding {
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
return self.view.window!
}
}
More generally, I'd like to ask:
What are the prerequisites to an SSO solution that we need to consider before implementation.
- Questions Like:
- What type of server required,
- Which auth services need to implement and why,
- Do we need to consider Apple configurator2 for implementing this?
- Questions Like:
Is there anything that need to be done at server-side? If yes, please explain it. I need to understand both the back-end and development perspectives.
There are two different types of extensions provided by iOS 13 for SSO implementations: redirect and credential.
So, how should we decide which extension to implement and why? What circumstances do we need to consider in making the decision?
