仅显示一次密码提示 - 如何?

发布于 2024-09-28 07:26:50 字数 419 浏览 1 评论 0原文

我正在构建一个 Cocoa 应用程序,该应用程序修改用户操作系统上的文件,这需要管理员权限。我有一个使用 authopen 的概念验证,但它没有提供我希望实现的用户体验体验。每次修改文件时,都会提示用户输入密码。有没有办法在应用程序的生命周期内授予应用程序权限?

目标: 应用程序要求用户输入密码一次,以后的应用程序不会提示输入密码。

下一个最佳: 应用程序在应用程序启动时要求用户输入密码一次,之后的应用程序不会提示输入密码,直到应用程序重新启动。

我知道授权服务以及创建专门处理修改特权文件的守护进程的可能性,我好奇的是,在深入研究之前,我列出的目标是否甚至可能实现另一个系统。

非常感谢任何建议、批评或有用的链接。

干杯, 达斯汀

I'm building an Cocoa application that modifies a file on the user's operating system which requires admin permission. I have a proof of concept working which uses authopen but it doesn't deliver the UX experience I am hoping to achieve. Every time the file is modified it prompts the user to enter their password. Is there a way to have permissions granted to the application for the duration of its life?

Goal:
Application asks user for password once ever, going forth application does not prompt for password.

Next Best:
Application asks user for password once at application launch, going forth application does not prompt for password until application restart.

I'm aware of Authorization Services and the possibility of creating a Daemon which deals specifically with modifying privileged files, what I'm curious about is if either of my listed goals are even possible before diving too deep into another system.

Really appreciate any suggestions, critiques or helpful links.

Cheers,
Dustin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一页 2024-10-05 07:26:50

是的,使用授权服务是前进的方向。您可以通过 AuthorizationCopyRights() 在应用程序中获取 AuthorizationRef (如果需要,它会显示 UI),并将其传递给您的帮助程序(通过将其打包到外部表单中),该帮助程序会在执行特权任务之前验证它是否确实获得了必要的权限。授权服务能够在 /etc/authorization 数据库中注册权限,因此,如果您选择自定义权限,您可以选择默认设置,规定允许谁获取该权限、存在什么超时或其他条件以及很快。

要部署特权帮助程序工具,您应该使用服务管理框架,特别是 SMJobBless(),它会在将帮助程序部署为 launchd 之前验证客户端和帮助程序上的代码签名身份是否匹配。工作。然后主应用程序可以根据需要启动您的助手。

如果您想澄清答案中的任何步骤,请随意询问,但是我已经在我的书中写了关于权限分离的这两个方面的内容 专业 Cocoa 应用程序安全性,所以请随意购买一两本;-)。

Yes, using Authorization Services is the way forward. You get an AuthorizationRef in your application via AuthorizationCopyRights() (which shows the UI if needed), and pass this to your helper (by packaging it up into an external form) which verifies that it actually got the necessary right before performing the privileged task. Authorization Services is able to register rights in the /etc/authorization database, so if you choose a custom right you can choose the default settings for who is allowed to acquire it, what timeout or other conditions exist and so on.

To deploy your privileged helper tool, you should use the Service Management framework, in particular SMJobBless() which verifies that the code signing identities on your client and helper match before deploying the helper as a launchd job. Then your helper can be initiated on demand by the main application.

Feel free to ask if you want clarification on any step in the answer, however I already wrote about both of these aspects of privilege separation in my book Professional Cocoa Application Security so feel free to buy a copy or two ;-).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文