Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Microsoft Authentication helper for macOS #19

Merged
merged 3 commits into from
Feb 2, 2019
Merged

Add Microsoft Authentication helper for macOS #19

merged 3 commits into from
Feb 2, 2019

Conversation

mjcheetham
Copy link
Collaborator

@mjcheetham mjcheetham commented Jan 29, 2019

Add the initial version of the Mac Microsoft Authentication Helper using ADAL 2.5.1 via CocoaPods. The pods are statically linked so only a single executable "Microsoft.Authentication.Helper" is required to be distributed with GCM.

Also include a script to create a macOS flat-package (.pkg) to install and configure GCM.

The Objective-C auth helper code is from the initial prototype created by @jamill.

Copy link
Contributor

@jrbriggs jrbriggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks great. A few things to consider.

macos/installer/scripts/configure-git.sh Show resolved Hide resolved
macos/installer/uninstall-gcm.sh Outdated Show resolved Hide resolved
PATH=""
eval $(/usr/libexec/path_helper -s)

git config --system credential.helper manager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we risk losing this configuration if Git is upgraded, like happens on Windows?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs around the Apple package installation system is pretty lacking. From my understanding I've created just a 'flat, component package' rather than a distribution package (containing multiple component packages).

Component packages have only a pre- and postinstall scripts which are run for each installation of the package. Distribution packages include more event scripts in addition to pre/postinstall (first install), such as pre/postupgrade (when a component already exists), pre/postflight (before and after the distribution package, made up of multiple component packages as a whole is installed).

If my understanding is correct (it might not be), then postinstall should be called everytime and thus GCM will be reconfigured each time.

Windows GCM is actually reconfiguring itself each time, AFAIK, because it's always invoking itself as git-credential-manager deploy which goes through and updated all the Git installations' configurations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at what is required on Windows to correctly 'install' GCM, it it probably a reasonable idea to have the configuration logic sit inside GCM itself (much saner and easier to test C# than setup packages and scripts).

If that is the case, it would therefore also make sense for the configuration logic for macOS to also live inside GCM. I had opted not to do this yet however because 1) need to discuss the problems faced with the rest of the team, and 2) this current method is cheap, cheerful, and (relatively) simple/good enough for now.

Comments?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your assessment and understanding of the Apple package installation system matches mine, so I think this works as you expect it to.

I'm torn on if it should live inside the GCM or inside the installer, but I think the postinstall script makes sense for now.

macos/Microsoft.Authentication.Helper/Source/Core/Logger.m Outdated Show resolved Hide resolved
macos/Microsoft.Authentication.Helper/Source/main.m Outdated Show resolved Hide resolved
@jrbriggs
Copy link
Contributor

@jamill I would appreciate your eyes on this PR too.

Copy link

@nickgra nickgra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a closer look at the obj-c later, but this is looking good.

PKGPAYLOAD=$INSTALLEROUT/payload

# Parse script arguments
for i in "$@"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This arg parser scares me. Since it's only being called by automation (other than you locally iterating on it to write it of course), can we make this simpler? Maybe just error out if $1 and $2 aren't set correctly?

macos/installer/uninstall-gcm.sh Outdated Show resolved Hide resolved
PATH=""
eval $(/usr/libexec/path_helper -s)

git config --system credential.helper manager
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your assessment and understanding of the Apple package installation system matches mine, so I think this works as you expect it to.

I'm torn on if it should live inside the GCM or inside the installer, but I think the postinstall script makes sense for now.

macos/installer/scripts/configure-git.sh Show resolved Hide resolved
@hi-kumar
Copy link

Not sure if this impacts this tool. We had to revert ApexBugger to use ADAL 2.5.1 due to known issue with more recent ADAL releases that can log a non-critical message to stderr. Those messages can be misinterpreted by callers of the executables as critical errors.
ADAL Issue 1362

Add the initial version of the Mac Microsoft Authentication Helper
using ADAL 2.5.1 via CocoaPods. The pods are statically linked so
only a single executable "Microsoft.Authentication.Helper" is
required to be distributed with GCM.

ADAL 2.5.1 was chosen because later ADAL versions include a bug
where errors were being written to standard error:

AzureAD/azure-activedirectory-library-for-objc#1362
@mjcheetham
Copy link
Collaborator Author

Thanks for the review @HiKumar-MS! 😃
Ah yes, that's an interesting ADAL bug. Technically the warning messages from ADAL to stderr shouldn't get in the way of GCM or Git, but I've downgraded anyway as it could appear as noise in the terminal for users non-the-less, which is ugly.

Copy link
Contributor

@jrbriggs jrbriggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me now. Were you able to test with VFS for Git to make sure the new way we install fixes the issue with Git not finding credential-manager when invoked from GVFS.Mount?

Add a simple flat-package installer with postinstall script
to configure the user's system gitconfig.
Update the Azure Pipelines YAML for macOS to build the Microsoft
Authentication helper using Xcode and also build & publish the
installer package.
Copy link

@nickgra nickgra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now after making the changes. I'm running it now and it seems to be working well!

@mjcheetham mjcheetham merged commit f54a51b into git-ecosystem:master Feb 2, 2019
@mjcheetham mjcheetham deleted the macos-msauth-helper branch February 2, 2019 11:03
@mjcheetham mjcheetham added enhancement New feature or request platform:osx Specific to the macOS platform labels Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform:osx Specific to the macOS platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants