Skip to content

Commit

Permalink
added key for skipping verification
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Jun 5, 2022
1 parent ea56a25 commit ee6c77c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 27 deletions.
26 changes: 25 additions & 1 deletion Profile Manifest/com.twocanoes.xCreds.plist
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,31 @@ A profile can consist of payloads with different version numbers. For example, c
<string></string>

</dict>


<dict>
<key>pfm_name</key>
<string>verifyPassword</string>
<key>pfm_type</key>
<string>boolean</string>
<key>pfm_title</key>
<string>Verify Cloud Password</string>
<key>pfm_description</key>
<string>Show prompt to verify cloud password before setting keychain and login.</string>
<key>pfm_default</key>
<integer>1</integer>

</dict>

<dict>
<key>pfm_name</key>
<string>showDebug</string>
<key>pfm_type</key>
<string>boolean</string>
<key>pfm_title</key>
<string>Show Debug Message</string>
<key>pfm_description</key>
<string>Show debug local notifications.</string>
</dict>
</array>
</dict>
</plist>
50 changes: 28 additions & 22 deletions XCreds/MainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,38 @@ class MainController: NSObject {
let localPassword = self.localPassword()

if let localPassword = localPassword {
let verifyOIDPassword = VerifyOIDCPasswordWindowController.init(windowNibName: NSNib.Name("VerifyOIDCPassword"))
NSApp.activate(ignoringOtherApps: true)

while true {
let response = NSApp.runModal(for: verifyOIDPassword.window!)
if response == .cancel {
verifyOIDPassword.window?.close()
break
}
let verifyCloudPassword = verifyOIDPassword.password

if verifyCloudPassword == cloudPassword {
try? PasswordUtils.changeLocalUserAndKeychainPassword(localPassword, newPassword1: cloudPassword, newPassword2: cloudPassword)
let err = keychainUtil.updatePassword("local password", pass: cloudPassword)
if err == false {
//TODO: Log Error
if UserDefaults.standard.bool(forKey: PrefKeys.verifyPassword.rawValue)==true {
let verifyOIDPassword = VerifyOIDCPasswordWindowController.init(windowNibName: NSNib.Name("VerifyOIDCPassword"))
NSApp.activate(ignoringOtherApps: true)

while true {
let response = NSApp.runModal(for: verifyOIDPassword.window!)
if response == .cancel {
verifyOIDPassword.window?.close()
break
}
let verifyCloudPassword = verifyOIDPassword.password
if verifyCloudPassword == cloudPassword {
try? PasswordUtils.changeLocalUserAndKeychainPassword(localPassword, newPassword1: cloudPassword, newPassword2: cloudPassword)
let err = keychainUtil.updatePassword("local password", pass: cloudPassword)
if err == false {
//TODO: Log Error
}
verifyOIDPassword.window?.close()
break;
}
else {
verifyOIDPassword.window?.shake(self)
}

verifyOIDPassword.window?.close()
break;

}
else {
verifyOIDPassword.window?.shake(self)
}
else {
try? PasswordUtils.changeLocalUserAndKeychainPassword(localPassword, newPassword1: cloudPassword, newPassword2: cloudPassword)
let err = keychainUtil.updatePassword("local password", pass: cloudPassword)
if err == false {
//TODO: Log Error
}

}


Expand Down
2 changes: 1 addition & 1 deletion XCreds/PrefKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import Foundation

enum PrefKeys: String {
case clientID, clientSecret, discoveryURL, redirectURI, scopes, accessToken, idToken, refreshToken, tokenEndpoint, expirationDate, invalidToken, refreshRate
case clientID, clientSecret, discoveryURL, redirectURI, scopes, accessToken, idToken, refreshToken, tokenEndpoint, expirationDate, invalidToken, refreshRate, showDebug, verifyPassword
}
14 changes: 11 additions & 3 deletions XCreds/ScheduleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,25 @@ class ScheduleManager {
TokenManager.shared.getNewAccessToken(completion: { isSuccessful, hadConnectionError in

if hadConnectionError==true {
NotifyManager.shared.sendMessage(message: "Could not check token.")
if UserDefaults.standard.bool(forKey: PrefKeys.showDebug.rawValue) == true {

NotifyManager.shared.sendMessage(message: "Could not check token.")
}

return
}
else if isSuccessful == true {
NotifyManager.shared.sendMessage(message: "Azure password unchanged")
if UserDefaults.standard.bool(forKey: PrefKeys.showDebug.rawValue) == true {
NotifyManager.shared.sendMessage(message: "Azure password unchanged")
}

}
else {
self.stopCredentialCheck()
NotifyManager.shared.sendMessage(message: "Azure password changed or not set")
if UserDefaults.standard.bool(forKey: PrefKeys.showDebug.rawValue) == true {

NotifyManager.shared.sendMessage(message: "Azure password changed or not set")
}
DispatchQueue.main.async {
mainMenu.webView = WebViewController()
mainMenu.webView?.window!.forceToFrontAndFocus(nil)
Expand Down
4 changes: 4 additions & 0 deletions XCreds/defaults.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
<string>xcreds:https://auth/</string>
<key>refreshRate</key>
<string>60</string>
<key>showDebug</key>
<false/>
<key>verifyPassword</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,22 @@
uuid = "94C20054-8AB3-42DB-93A7-A3026166D6FC"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "1E23C051-89B9-494D-A3BF-413E78FF407C"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/ScheduleManager.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "38"
endingLineNumber = "38"
landmarkName = "checkToken()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

0 comments on commit ee6c77c

Please sign in to comment.