At Apple Labs engineer told me to use LAContext ( LocalAuthentication.framework ), because this object is adopting NSSecureCoding protocol and can be used to authenticate user.
The flow is simple.
Create LAContext at main GUI.
Authenticate user via canEvaluatePolicy() and evaluatePolicy()
Send LAContext through XPC to your desired service.
Call canEvaluatePolicy() and evaluatePolicy() again.
However, I have a problem with last part.
I made a wrapper object which carries LAContext through XPC. ( AuthorizationPayload ).
It works fine and carries LAContext to service from main GUI.
However, when I try to verify LAContext on service side, I receive errors:
LAContext[61791:0] failed to initialize: Error Domain=com.apple.LocalAuthentication Code=-10 "Context not found." UserInfo={NSDebugDescription=Context not found., NSLocalizedDescription=Authentication failure.}
and
canEvaluatePolicy() also returns false with the same error.
Additional.
I also added this sandbox rule to my service.
(allow mach-lookup
(global-name "com.apple.CoreAuthentication.daemon")
)
What can I do in this situation?