Posted on 08-07-2018 05:04 AM
Hey all,
Anyone using class link for their SSO solution? We are about to implement it and I'm working on pushing out the web extensions and as always didn't want to re invent the wheel.
Any best practices when pushing browser extensions?
Gabe Shackney
Princeton Public Schools
Posted on 08-14-2018 08:48 AM
I'm in the same boat. About to start looking at this.
Posted on 08-16-2018 10:02 AM
@gshackney apparently this is not that easy of a process. The only approved methods of installing a Safari extension are via the Safari Extension Gallery or by opening the extension file in Safari as the user. So this would have to be done for each user from my research. I've come up with a script that will make the installation very easy by the user, but it does not happen in the background.
#!/bin/bash
timeout=$((SECONDS+120))
extensionURL="https://dp3vjvsy1r9i0.cloudfront.net/resources/browserextensions/classlink-oneclick-safari.safariextz"
extensionName=${extensionURL##*/}
initialExtCount=$(find "$HOME/Library/Safari/Extensions" -type f -name "*.safariextz" | wc -l | awk '{print $1}')
function finish () {
# Restore our backup so we don't have to curl for the next user
mv /private/tmp/$extensionName.bak /private/tmp/$extensionName 2&> /dev/null
exit "$1"
}
# Make sure the Dock/Desktop is loaded before moving on
dockStatus=$(pgrep -x Dock)
while [[ "$dockStatus" == "" ]]; do
sleep 5
dockStatus=$(pgrep -x Dock)
done
# Curl down the extension if it does not exist
if [[ ! -f "/private/tmp/$extensionName" ]]; then
if curl -o "/private/tmp/$extensionName" "$extensionURL" ; then
sleep 1
else
echo "Could not download extension; exiting."
finish 1
fi
fi
# Installing the extension deletes it, so let's make a backup
cp /private/tmp/$extensionName /private/tmp/$extensionName.bak
# Open the extension
open "/private/tmp/$extensionName"
# Extension gets deleted after installation - wait for the file to dissappear or our timeout
while [[ -f "/private/tmp/$extensionName" ]] && [[ $SECONDS -lt $timeout ]]; do
sleep 2
done
# Check to see if the extension gets installed into the user's Safari extensions directory
currentExtCount=$(find "$HOME/Library/Safari/Extensions" -type f -name "*.safariextz" | wc -l | awk '{print $1}')
if [[ "$currentExtCount" -gt "$initialExtCount" ]]; then
echo "Successfully installed the extension; exiting."
finish 0
else
echo "Failed to install the extension; exiting."
finish 1
fi
HOWEVER, I've taken a different route. I can get the ClassLink extension in Chrome very easily by using a Config Profile for domain com.google.Chrome as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ExtensionInstallForcelist</key>
<!-- ClassLink Extension -->
<!-- https://chrome.google.com/webstore/detail/classlink-oneclick-extens/jgfbgkjjlonelmpenhpfeeljjlcgnkpe?hl=en -->
<array>
<string>jgfbgkjjlonelmpenhpfeeljjlcgnkpe;https://clients2.google.com/service/update2/crx</string>
<string>jgfbgkjjlonelmpenhpfeeljjlcgnkpe</string>
</array>
</dict>
</plist>
Then I created an Automator app called "ClassLink Launcher.app" that uses the "run shell script" setting with the below script. When a user runs the app, it will launch our ClassLink site in Chrome, and then asks (once) if they want the ClassLink Launcher.app added to their Dock.
#!/bin/bash
jamfHelper=/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper
icon="/Applications/ClassLink Launcher.app/Contents/Resources/AutomatorApplet.icns"
pref="$HOME/Library/Preferences/org.your_corp.ClassLinkDock.plist"
open -a "Google Chrome" https://launchpad.classlink.com/your_corp
if [[ ! -f "$pref" ]]; then
sleep 3
prompt=$("$jamfHelper" -windowType utility -icon "$icon" -title "ClassLink Launcher"
-description "Would you like a shortcut to ClassLink added to your Dock?"
-button1 "Yes" -button2 "No" -defaultButton "1" -cancelButton "2" -alignDescription "natural" -timeout "120")
if [[ "$prompt" == "0" ]]; then
/usr/local/bin/dockutil --add "/Applications/ClassLink Launcher.app"
fi
fi
touch "$pref"
exit 0