Coder Social home page Coder Social logo

oskargroth / swiftprivilegedhelper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from erikberglund/swiftprivilegedhelper

2.0 1.0 0.0 874 KB

Example application using a privileged helper tool with authentication written in Swift

Swift 100.00%

swiftprivilegedhelper's Introduction

SwiftPrivilegedHelper

This is an example application to demonstrate how to use a privileged helper tool with authentication in Swift 3.0.

Please undestand the code and improve and customize it to suit your needs and your application. The example code contain minimal error handling and can be improved in many ways.

Index

Requirements

  • Tool and language versions
    This project was created and only tested using Xcode Version 8.1 (8B62) and Swift 3.0.

  • Developer Certificate
    To use a privileged helper tool the application and helper has to be signed by a valid deverloper certificate.
    I'm using manual signing with a Developer ID certificate in the application, so the guide will assume that setup.

  • SMJobBlessUtil
    The python tool for verifying signing of applications using SMJobBless included in the SMJobBless example project is extremely useful for troubleshooting signing issues.

Dowload it here: SMJobBlessUtil.py

Use it like this: ./SMJobBlessUtil.py check /path/to/MyApplication.app

Setup

To test the project, you need to update it to use your own signing certificate.

Select signing team

  1. Select the project in the navigator.
  2. For both the application and helper targets:
  3. Change the signing Team to your Team.
    ChangeSigningTeam

Change signing certificate OU

  1. Find the OU of the Developer ID certificate you selected in the application:
$ grep DevelopmentTeam /path/to/SwiftPrivilegedHelper/MyApplication.xcodeproj/project.pbxproj
DevelopmentTeam = Y7QFC8672N;
  1. For both the application and helper Info.plist:
  2. Replace the OU with your own in Tools owned after installation and Clients allowed to add and remove tool respectively.
    ChangeCertificateOU

Build and test the application.

Signing Troubleshooting

Use SMJobBlessUtil.py and correct all issues reported until it doesn't show any output.

Application

The helper is installed by using SMJobBless.

When installed, you can enter a directory path in the text field at the top and select to run the /bin/ls command (with the entered path as argument) using the helper tool with or without requiring authorization.

The application caches the authorization reference which means that you only have to authorize that action once until you press the "Destroy the cached authorization reference" or restart the application.

This behaviour can easily be changed to either require authrization every time, after x seconds or never.

References

Links to documentation on the authorization system on macOS.

swiftprivilegedhelper's People

Stargazers

 avatar Oleksandr Yakubchyk avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.