Skip to content

Commit

Permalink
added idhostnames array so you can specify multiple tenants
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Oct 14, 2022
1 parent d8658f3 commit 663dfa9
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 13 deletions.
19 changes: 19 additions & 0 deletions Profile Manifest/com.twocanoes.xcreds.plist
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,25 @@ A profile can consist of payloads with different version numbers. For example, c
<key>pfm_type</key>
<string>string</string>
</dict>
<dict>
<key>pfm_description</key>
<string>array of hostnames of the page that has the password field.</string>
<key>pfm_name</key>
<string>idpHostNames</string>
<key>pfm_subkeys</key>
<array>
<dict>
<key>pfm_name</key>
<string>idpHostName</string>
<key>pfm_type</key>
<string>string</string>
</dict>
</array>
<key>pfm_title</key>
<string>idpHostNames</string>
<key>pfm_type</key>
<string>array</string>
</dict>
<dict>
<key>pfm_description</key>
<string>password element id of the html element that has the password.</string>
Expand Down
2 changes: 1 addition & 1 deletion XCreds/PrefKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

enum PrefKeys: String {
case clientID, clientSecret, password="local password",discoveryURL, redirectURI, scopes, accessToken, idToken, refreshToken, tokenEndpoint, expirationDate, invalidToken, refreshRateHours, showDebug, verifyPassword, shouldShowQuitMenu, shouldShowPreferencesOnStart, shouldSetGoogleAccessTypeToOffline, passwordChangeURL, shouldShowAboutMenu, username, idpHostName, passwordElementID, shouldShowVersionInfo, shouldShowSupportStatus,shouldShowConfigureWifiButton,shouldShowMacLoginButton, loginWindowBackgroundImageURL, shouldShowCloudLoginByDefault
case clientID, clientSecret, password="local password",discoveryURL, redirectURI, scopes, accessToken, idToken, refreshToken, tokenEndpoint, expirationDate, invalidToken, refreshRateHours, showDebug, verifyPassword, shouldShowQuitMenu, shouldShowPreferencesOnStart, shouldSetGoogleAccessTypeToOffline, passwordChangeURL, shouldShowAboutMenu, username, idpHostName, passwordElementID, shouldShowVersionInfo, shouldShowSupportStatus,shouldShowConfigureWifiButton,shouldShowMacLoginButton, loginWindowBackgroundImageURL, shouldShowCloudLoginByDefault,idpHostNames
}
func getManagedPreference(key: Preferences) -> Any? {

Expand Down
8 changes: 6 additions & 2 deletions XCreds/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ extension WebViewController: WKNavigationDelegate {
// TCSLogWithMark("DecidePolicyFor: \(navigationAction.request.url?.absoluteString ?? "None")")

let idpHostName = UserDefaults.standard.value(forKey: PrefKeys.idpHostName.rawValue)
var idpHostNames = UserDefaults.standard.value(forKey: PrefKeys.idpHostNames.rawValue)

if idpHostNames == nil && idpHostName != nil {
idpHostNames=[idpHostName]
}
let passwordElementID:String? = UserDefaults.standard.value(forKey: PrefKeys.passwordElementID.rawValue) as? String
if let idpHostName = idpHostName as? String, navigationAction.request.url?.host == idpHostName, let passwordElementID = passwordElementID {
if let idpHostNames = idpHostNames as? Array<String?>, idpHostNames.contains(navigationAction.request.url?.host), let passwordElementID = passwordElementID {
TCSLogWithMark("host matches custom idpHostName")
TCSLogWithMark("passwordElementID is \(passwordElementID)")

TCSLogWithMark(idpHostName.sanitized())
TCSLogWithMark("inserting javascript to get password")

let javaScript = "document.getElementById('\(passwordElementID.sanitized())').value"
Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3292;
CURRENT_PROJECT_VERSION = 3295;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -924,7 +924,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3292;
CURRENT_PROJECT_VERSION = 3295;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -983,7 +983,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3292;
CURRENT_PROJECT_VERSION = 3295;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1013,7 +1013,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3292;
CURRENT_PROJECT_VERSION = 3295;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1156,7 +1156,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3292;
CURRENT_PROJECT_VERSION = 3295;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1185,7 +1185,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3292;
CURRENT_PROJECT_VERSION = 3295;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,49 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "3EC3D20A-D116-4A30-89DE-1FD9BEBCE31A"
uuid = "BCE0840D-9540-4B91-A831-47B11704A608"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/WebView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "249"
endingLineNumber = "249"
landmarkName = "tokenResponse(tokens:)"
startingLineNumber = "78"
endingLineNumber = "78"
landmarkName = "webView(_:decidePolicyFor:decisionHandler:)"
landmarkType = "7">
<Locations>
<Location
uuid = "BCE0840D-9540-4B91-A831-47B11704A608 - 48d6d7678f29c86b"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "XCreds.WebViewController.webView(_: __C.WKWebView, decidePolicyFor: __C.WKNavigationAction, decisionHandler: (__C.WKNavigationActionPolicy) -&gt; ()) -&gt; ()"
moduleName = "XCreds"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/tperfitt/Documents/Projects/xcreds/XCreds/WebView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "78"
endingLineNumber = "78"
offsetFromSymbolStart = "1140">
</Location>
<Location
uuid = "BCE0840D-9540-4B91-A831-47B11704A608 - 48d6d7678f29c86b"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "XCreds.WebViewController.webView(_: __C.WKWebView, decidePolicyFor: __C.WKNavigationAction, decisionHandler: (__C.WKNavigationActionPolicy) -&gt; ()) -&gt; ()"
moduleName = "XCreds"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/tperfitt/Documents/Projects/xcreds/XCreds/WebView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "78"
endingLineNumber = "78"
offsetFromSymbolStart = "1337">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
Expand Down

0 comments on commit 663dfa9

Please sign in to comment.