Skip to content

Commit

Permalink
Feature Request: Allow "loadpage.html" to be customized. #126. To tes…
Browse files Browse the repository at this point in the history
…t, add in new keys "loadPageTitle" and "loadPageInfo" or try the xcreds_example_azure_loadPageTitle_loadPageInfo.mobileconfig
  • Loading branch information
twocanoes committed Jan 1, 2024
1 parent ff9dc64 commit 37c7477
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
35 changes: 35 additions & 0 deletions Profile Manifest/com.twocanoes.xcreds.plist
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,41 @@ A profile can consist of payloads with different version numbers. For example, c
<key>pfm_type</key>
<string>integer</string>
</dict>


<dict>
<key>pfm_default</key>
<string>Please Wait....</string>
<key>pfm_description</key>
<string>When no network connection or a profile is not defined, this title is shown in an HTML view to the user when cloud login is configured.</string>
<key>pfm_documentation_url</key>
<string>https://twocanoes.com/knowledge-base/xcreds-admin-guide/#preferences</string>
<key>pfm_name</key>
<string>loadPageTitle</string>
<key>pfm_title</key>
<string>LoadPage Title</string>
<key>pfm_type</key>
<string>string</string>
</dict>
<dict>
<key>pfm_default</key>
<string>(or try connecting to network or check preferences)</string>
<key>pfm_description</key>
<string>When no network connection or a profile is not defined, this text is shown in an HTML view to the user when cloud login is configured.</string>
<key>pfm_documentation_url</key>
<string>https://twocanoes.com/knowledge-base/xcreds-admin-guide/#preferences</string>
<key>pfm_name</key>
<string>LoadPage Info</string>
<key>pfm_title</key>
<string>LoadPage Info</string>
<key>pfm_type</key>
<string>string</string>
</dict>





<dict>
<key>pfm_default</key>
<string>file:///System/Library/Desktop Pictures/Monterey Graphic.heic</string>
Expand Down
2 changes: 1 addition & 1 deletion XCreds/PrefKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

enum PrefKeys: String {
case clientID, clientSecret, password="xcreds local password",discoveryURL, redirectURI, scopes, accessToken, idToken, refreshToken, tokenEndpoint, expirationDate, invalidToken, refreshRateHours,refreshRateMinutes, showDebug, verifyPassword, shouldShowQuitMenu, shouldShowPreferencesOnStart, shouldSetGoogleAccessTypeToOffline, passwordChangeURL, shouldShowAboutMenu, username, idpHostName, passwordElementID, shouldFindPasswordElement, shouldShowVersionInfo, shouldShowSupportStatus,shouldShowConfigureWifiButton,shouldShowMacLoginButton, loginWindowBackgroundImageURL, shouldShowCloudLoginByDefault, shouldPreferLocalLoginInsteadOfCloudLogin, idpHostNames,autoRefreshLoginTimer, loginWindowWidth, loginWindowHeight, shouldShowRefreshBanner, shouldSwitchToLoginWindowWhenLocked,accounts = "Accounts",
windowSignIn = "WindowSignIn", settingsOverrideScriptPath, localAdminUserName, localAdminPassword, usernamePlaceholder, passwordPlaceholder, shouldShowLocalOnlyCheckbox, shouldShowTokenUpdateStatus, shouldDetectNetworkToDetermineLoginWindow, showLoginWindowDelaySeconds, shouldPromptForMigration, shouldAllowKeyComboForMacLoginWindow, aliasName,claimsToAddToLocalUserAccount
windowSignIn = "WindowSignIn", settingsOverrideScriptPath, localAdminUserName, localAdminPassword, usernamePlaceholder, passwordPlaceholder, shouldShowLocalOnlyCheckbox, shouldShowTokenUpdateStatus, shouldDetectNetworkToDetermineLoginWindow, showLoginWindowDelaySeconds, shouldPromptForMigration, shouldAllowKeyComboForMacLoginWindow, aliasName,claimsToAddToLocalUserAccount, loadPageTitle, loadPageInfo
//, filePathToPreventShowingUI
case shouldVerifyPasswordWithRopg
case shouldUseROPGForOIDCLogin
Expand Down
17 changes: 9 additions & 8 deletions XCreds/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ class WebViewController: NSViewController, TokenManagerFeedbackDelegate {

}

let bundle = Bundle.findBundleWithName(name: "XCreds")
let loadPageTitle = DefaultsOverride.standardOverride.string(forKey: PrefKeys.loadPageTitle.rawValue)

let loadPageInfo = DefaultsOverride.standardOverride.string(forKey: PrefKeys.loadPageInfo.rawValue)

if let loadPageTitle = loadPageTitle?.stripped,
let loadPageInfo = loadPageInfo?.stripped {
let html = "<!DOCTYPE html><html><head><style>.center-screen { display: flex;flex-direction: column;justify-content: center;align-items: center;text-align: center;min-height: 100vh;}</style></head><body><div class=\"center-screen\"> <h1>\(loadPageTitle)</h1><p>\(loadPageInfo)</p></div></body></html>"

self.webView.loadHTMLString(html, baseURL: nil)

if let bundle = bundle {
TCSLogWithMark("getting loadPageURL")
let loadPageURL = bundle.url(forResource: "loadpage", withExtension: "html")
if let loadPageURL = loadPageURL {
TCSLogWithMark("loading webview")
self.webView.load(URLRequest(url:loadPageURL))
}

}
}
Expand Down
4 changes: 4 additions & 0 deletions XCreds/defaults.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@
<array>
<string>groups</string>
</array>
<key>loadPageTitle</key>
<string>Please Wait....</string>
<key>loadPageInfo</key>
<string>(or try connecting to network or check preferences)</string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
76EECD0228752C1F00483C66 /* LoginWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 766355E128713C47002E3867 /* LoginWindow.swift */; };
76EECD0428753C7F00483C66 /* String+Base64URLEncoded.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EECD0328753C7F00483C66 /* String+Base64URLEncoded.swift */; };
76EECD0528753C7F00483C66 /* String+Base64URLEncoded.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EECD0328753C7F00483C66 /* String+Base64URLEncoded.swift */; };
76F0B6E02B421FC8008F7D71 /* loadpage.html in Resources */ = {isa = PBXBuildFile; fileRef = 7613FDF6289E114F00340CCD /* loadpage.html */; };
76FDC5D62B22D47A0035D61E /* MainLoginWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76FDC5D42B22D47A0035D61E /* MainLoginWindowController.swift */; };
76FDC5D72B22D47A0035D61E /* MainLoginWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 76FDC5D52B22D47A0035D61E /* MainLoginWindowController.xib */; };
76FDC5DA2B235A4F0035D61E /* StatusMenuWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76FDC5D82B235A4F0035D61E /* StatusMenuWindowController.swift */; };
Expand Down Expand Up @@ -1140,6 +1141,7 @@
76D1756A2B23C28700E64A62 /* MainLoginWindowController.xib in Resources */,
76EE06B227FD1E24009E0F3A /* DesktopLoginWindowController.xib in Resources */,
7681FEC92A4CFEA200F91CD1 /* com.twocanoes.xcreds.plist in Resources */,
76F0B6E02B421FC8008F7D71 /* loadpage.html in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.

0 comments on commit 37c7477

Please sign in to comment.