SFAuthorizationPluginView Implementation in Swift

Hi,

I am currently trying to develop an authorization plugin using SFAuthorizationPluginView. My objective is to display a webView to the user for authentication purposes. I have based my work on the updated NameandPassword example : https://github.com/antoinebell/NameAndPassword.

I have seen that the header for the SFAuthorizationPluginView class exists in Swift. However, I have not found any implementation examples of an authorization plugin in Swift. I have attempted to implement this on my own but am encountering difficulties displaying my embedded view within a ViewController. Is it possible to create an authorization plug-in in Swift ?

Answered by DTS Engineer in 796439022

I’d like you to submit a code-level support request so that I can share some stuff with you. Once that’s done, we can continue the discussion here in the forums. When you create the request, indicate that you were referred by someone at Apple and make sure to include a link to this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I’d like you to submit a code-level support request so that I can share some stuff with you. Once that’s done, we can continue the discussion here in the forums. When you create the request, indicate that you were referred by someone at Apple and make sure to include a link to this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi,

I have reviewed and tested the provided examples, and I would need some additional information.

I would like to dynamically display elements (input fields, images, buttons) on the login and lock screens.

When using an NSWindow (GUIAuthPlugin), I encountered an issue with loading this custom UI on the lock screen, and I haven’t found any workaround to fix this problem. Is there one available?

When using the SFAuthorizationPluginView subclass (LoginUIView), I feel limited in terms of view size and element layout. Is it possible to hide the user photo and name so that the authorization plugin can handle displaying them? Also, is it possible to load a dynamically constructed view, for instance, using SwiftUI?

What would be the best approach for my case?

Thank you for your help.

Sorry I didn’t get back to you sooner; I missed your reply )-:

When using an NSWindow (GUIAuthPlugin), I encountered an issue with loading this custom UI on the lock screen, and I haven’t found any workaround to fix this problem. Is there one available?

No. The GUIAuthPlugin read me doc makes that very clear:

Starting with macOS 10.13 it’s no longer possible to display a custom window from an authorization plug-in running in the screen saver context (that is, when invoked by the system.login.screensaver right). This is not a bug but a deliberate change, made as part of a security hardening effort.

Is it possible to hide the user photo and name so that the authorization plugin can handle displaying them?

No.

is it possible to load a dynamically constructed view, for instance, using SwiftUI?

Sure, but with two restrictions:

  • Everything has to fit within the space available which, as you noted, can be a challenge.

  • Your root view still has to come from a nib. So, if you want to use SwiftUI specifically, that means you’ll need to wrap it in NSHostingView.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

SFAuthorizationPluginView Implementation in Swift
 
 
Q