How to customize the Mac OSX login?

2020-02-11 04:02发布

I need to customize the whole login screen and functionality for any Apple`s Macbook.

The general idea is to have control under the user credentials to authenticate this user on a external authentication server.

Thus, it's important to customize the UI, like adding a new TextField for a second password input or displaying a image like a QR Code.

What I have done so far

After digging some research, I`ve found out only two relevant projects:

1 - https://github.com/skycocker/NameAndPassword

However it is from 4 years ago and it seems outdated.

2 - https://developer.apple.com/library/content/samplecode/PreLoginAgents/Introduction/Intro.html

And I've deployed the sample code for the PreLoginAgent from Apple, however it only opens an external application on login.

What I'm looking for

  • What is the most appropriated way to handle a customization inside the Mac OSX authentication?

Note: I'm looking for a solution where I can avoid breaking out the login as well.

1条回答
Fickle 薄情
2楼-- · 2020-02-11 04:51

I'm not sure why you discount your first link (NameAndPassword)

It's a "fixed" version of one of Apple's sample projects for SFAuthorizationPluginView. That is the class you need to use. Unfortunately as you see by Apple's own sample not compiling, and the very thin documentation, it might be tricky to get it working.

However, I took the project from the link above and compiled it on my machine.

Then I copied the resulting .bundle to /Library/Security/SecurityAgentPlugins

Next you need to register the plugin in the authorization database:

  1. security authorizationdb read system.login.console > outfile.plist
  2. Modify the outfileplist by replacing:

    <string>loginwindow:login</string>

with: <string>NameAndPassword:invoke</string>

  1. Now, update the database:

security authorizationdb write system.login.console < outfile.plist

Now, log out and the login screen will reflect the custom view.

Once installed, the link you provided is a good simple PoC. If you need additional help in customising your SFAuthorizationPluginView to do what you want, I suggest you post specific questions around that.

Just because the API is older does not mean it's out of date. The login screen has not changed a lot over the years. As for the out-of-date samples and poor documentation, that seems fairly typical of these more esoteric macOS developer features.

Useful links:

Customize Login Screen Mac OSX (SFAuthorizationPluginView)

Custom login/lock screen in OS X Mavericks

https://developer.apple.com/documentation/securityinterface/sfauthorizationpluginview

查看更多
登录 后发表回答