I have included two mechanisms in the LoginUIAuthPlugin (Authorization Plugin for MacOS). The authorization mechanisms run very well but second gets invoked before first is destroyed and then first gets invoked by itself. Both of them keep getting invoked infinitely.
They run perfectly and destroy nicely when either one of them is used separately. But, the issue is when both of them are in AuthorizationDB at the same time.
A class instance in Swift is destroyed automatically just like it destroys when only one mechanism is called. So, how can I fix this? Can I somehow call the destroy function manually? Or?
My AuthorizationDB:
I've just replaced the "loginwindow:login" with "LoginUIAuthPlugin:login" and added "LoginUIAuthPlugin:createUser,privileged" in the original AuthorizationDB file.
The log I get:
.
.
.
#Ending of First Mechanism:
#Second Mechanism Starts here:
#First Mechanism invokes again:
All that repeats infinitly. :(
Mechanisms are created by this code:
The class handling the second mechanism:
They run perfectly and destroy nicely when either one of them is used separately. But, the issue is when both of them are in AuthorizationDB at the same time.
A class instance in Swift is destroyed automatically just like it destroys when only one mechanism is called. So, how can I fix this? Can I somehow call the destroy function manually? Or?
My AuthorizationDB:
Code Block . . <key>mechanisms</key> <array> <string>builtin:policy-banner</string> <string>LoginUIAuthPlugin:login</string> <string>builtin:login-begin</string> <string>LoginUIAuthPlugin:createUser,privileged</string> <string>builtin:reset-password,privileged</string> <string>loginwindow:FDESupport,privileged</string> . .
I've just replaced the "loginwindow:login" with "LoginUIAuthPlugin:login" and added "LoginUIAuthPlugin:createUser,privileged" in the original AuthorizationDB file.
The log I get:
.
.
.
#Ending of First Mechanism:
Code Block 2020-10-16 10:55:51.551925+0500 0x240c mechanism -1 will set context username 2020-10-16 10:55:51.552335+0500 0x240c mechanism -1 did set context username 2020-10-16 10:55:51.552454+0500 0x240c mechanism -1 will set context password 2020-10-16 10:55:51.552520+0500 0x240c mechanism -1 did set context password 2020-10-16 10:55:51.552633+0500 0x240c mechanism -1 will set result 0 2020-10-16 10:55:51.554216+0500 0x240c mechanism -1 did set result 0 2020-10-16 10:55:51.554443+0500 0x240c mechanism -1 will did deactivate 2020-10-16 10:55:51.554508+0500 0x240c mechanism -1 did did deactivate
#Second Mechanism Starts here:
Code Block 2020-10-16 10:55:51.566353+0500 0x24af mechanism -1 will invoke 2020-10-16 10:55:51.566462+0500 0x24af LoginUICreateUserMechanism: invoke 2020-10-16 10:55:51.581631+0500 0x24af mechanism -1 will set result 0 2020-10-16 10:55:51.582208+0500 0x24af mechanism -1 did set result 0 2020-10-16 10:55:51.582247+0500 0x24af mechanism -1 will did deactivate 2020-10-16 10:55:51.582272+0500 0x24af mechanism -1 did did deactivate
#First Mechanism invokes again:
Code Block 2020-10-16 10:55:51.582314+0500 0x24af mechanism -1 did invoke 2020-10-16 10:55:53.869029+0500 0x240c mechanism -1 will invoke 2020-10-16 10:55:53.869406+0500 0x240c LoginUIAuthMechanism: invoke 2020-10-16 10:55:53.869520+0500 0x240c will display view 2020-10-16 10:55:53.874812+0500 0x240c will enable 2020-10-16 10:55:53.893029+0500 0x240c will return view for Username 2020-10-16 10:55:53.908530+0500 0x240c mechanism -1 did invoke
All that repeats infinitly. :(
Mechanisms are created by this code:
Code Block extension AuthPlugin: AuthPluginEntry { . . . return AuthPlugin.start( log: OSLog(subsystem: "com.example.apple-samplecode.LoginUIAuthPlugin", category: "plugin"), mechanismForID: { mechID, context in guard mechID.rawValue == "login" || mechID.rawValue == "createUserMech" else { throw AuthPlugin.noSuchMechanismError } switch mechID.rawValue { case "login": return LoginUIAuthMechanism(context: context) case "createUserMech": return LoginUICreateUserMechanism(context: context); default: throw AuthPlugin.noSuchMechanismError; } }, . . .
The class handling the second mechanism:
Code Block class LoginUICreateUserMechanism:AuthPlugin.Mechanism { var context: AuthPlugin.Context func invoke() throws { try! self.context.setResult(.allow) try! self.context.didDeactivate() } func deactivate() throws { globalLogger("LoginUICreateUserMechanism: deactivate") } func destroy() { globalLogger("LoginUICreateUserMechanism: destroy") } init(context: AuthPlugin.Context) { globalLogger("LoginUICreateUserMechanism: init") self.context = context } deinit { globalLogger("LoginUICreateUserMechanism: deinit") }