Skip to content

Commit

Permalink
fixed issue with updating keychain
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Jan 12, 2024
1 parent a76b7f8 commit d0b70c3
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 131 deletions.
2 changes: 1 addition & 1 deletion Profile Manifest/com.twocanoes.xcreds.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>pfm_app_url</key>
<string>https://github.com/twocanoes/xcreds</string>
<key>pfm_description</key>
<string>XCreds 4.0 (6212) OAuth Settings</string>
<string>XCreds 4.0 (6226) OAuth Settings</string>
<key>pfm_documentation_url</key>
<string>https://twocanoes.com/knowledge-base/xcreds-admin-guide/#preferences</string>
<key>pfm_domain</key>
Expand Down
4 changes: 4 additions & 0 deletions Shared/Tokens.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ struct Creds {
return (self.accessToken != nil) && (self.idToken != nil) && (self.refreshToken != nil)
}

func hasAccessAndRefresh() -> Bool {

return (self.accessToken != nil) && (self.refreshToken != nil)
}

}

Expand Down
7 changes: 4 additions & 3 deletions XCreds/MainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class MainController: NSObject, UpdateCredentialsFeedbackProtocol {
}
else if DefaultsOverride.standardOverride.value(forKey: PrefKeys.discoveryURL.rawValue) != nil && DefaultsOverride.standardOverride.value(forKey: PrefKeys.clientID.rawValue) != nil {

windowController.webViewController.updateCredentialsFeedbackDelegate=self
windowController.window!.makeKeyAndOrderFront(self)
windowController.webViewController?.loadPage()
}
Expand Down Expand Up @@ -200,8 +201,8 @@ class MainController: NSObject, UpdateCredentialsFeedbackProtocol {
DispatchQueue.main.async {
self.windowController.window?.close()
let localAccountAndPassword = self.localAccountAndPassword()
if var localPassword=localAccountAndPassword.1{
if (localPassword != credentials.password){
if credentials.password != nil, var localPassword=localAccountAndPassword.1{
if localPassword != credentials.password{
var updatePassword = true
if DefaultsOverride.standardOverride.bool(forKey: PrefKeys.verifyPassword.rawValue)==true {
let verifyOIDPassword = VerifyOIDCPasswordWindowController.init(windowNibName: NSNib.Name("VerifyOIDCPassword"))
Expand Down Expand Up @@ -250,7 +251,7 @@ class MainController: NSObject, UpdateCredentialsFeedbackProtocol {
}
}
}
if TokenManager.saveTokensToKeychain(creds: credentials, setACL: true, password:credentials.password ) == false {
if TokenManager.saveTokensToKeychain(creds: credentials, setACL: true, password:localAccountAndPassword.1 ) == false {
TCSLogErrorWithMark("error saving tokens to keychain")
}
self.scheduleManager.startCredentialCheck()
Expand Down
2 changes: 1 addition & 1 deletion XCreds/TokenManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ extension TokenManager {
RunLoop.main.perform {

let xcredCreds = Creds(password: nil, tokens: tokens)
if xcredCreds.hasTokens(){
if xcredCreds.hasAccessAndRefresh(){
self.feedbackDelegate?.credentialsUpdated(xcredCreds)
}
else {
Expand Down
7 changes: 5 additions & 2 deletions XCreds/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ class WebViewController: NSViewController, TokenManagerFeedbackDelegate {
TCSLogWithMark()
var credWithPass = credentials
credWithPass.password = self.password
NotificationCenter.default.post(name: Notification.Name("TCSTokensUpdated"), object: self, userInfo:["credentials":credWithPass]
)
// NotificationCenter.default.post(name: Notification.Name("TCSTokensUpdated"), object: self, userInfo:["credentials":credWithPass]
// )

updateCredentialsFeedbackDelegate?.credentialsUpdated(credWithPass)
}

@IBOutlet weak var refreshTitleTextField: NSTextField?
@IBOutlet weak var webView: WKWebView!
@IBOutlet weak var cancelButton: NSButton!
var tokenManager=TokenManager()
var password:String?
var updateCredentialsFeedbackDelegate: UpdateCredentialsFeedbackProtocol?

func loadPage() {
DispatchQueue.main.async {
Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6225;
CURRENT_PROJECT_VERSION = 6229;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1469,7 +1469,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6225;
CURRENT_PROJECT_VERSION = 6229;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1590,7 +1590,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6225;
CURRENT_PROJECT_VERSION = 6229;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1627,7 +1627,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6225;
CURRENT_PROJECT_VERSION = 6229;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1777,7 +1777,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6225;
CURRENT_PROJECT_VERSION = 6229;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1819,7 +1819,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6225;
CURRENT_PROJECT_VERSION = 6229;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,127 +7,16 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "5B3B8DAB-FECD-4F85-B08A-BB61A680A41D"
uuid = "8F546B93-D7A6-49A8-8BC5-1E81F6F4A494"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "KlistUtil.swift"
filePath = "XCreds/TokenManager.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "151"
endingLineNumber = "151"
landmarkName = "klist()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "0D2DD721-F105-4A81-98A5-5EFF44E3BC69"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "KlistUtil.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "154"
endingLineNumber = "154"
landmarkName = "klist()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "EF6F795C-F6EE-40F5-9005-04332F7BEF91"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCredsLoginPlugIn/LoginWindow/SignInWindowController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "196"
endingLineNumber = "196"
landmarkName = "showResetUI()"
landmarkType = "7">
<Locations>
<Location
uuid = "EF6F795C-F6EE-40F5-9005-04332F7BEF91 - f6f721ff691f5653"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "XCreds.SignInViewController.showResetUI() -&gt; Swift.Bool"
moduleName = "XCreds"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/tperfitt/Documents/Projects/xcreds/XCredsLoginPlugIn/LoginWindow/SignInWindowController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "197"
endingLineNumber = "197"
offsetFromSymbolStart = "1752">
</Location>
<Location
uuid = "EF6F795C-F6EE-40F5-9005-04332F7BEF91 - f6f721ff691f5653"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "XCreds.SignInViewController.showResetUI() -&gt; Swift.Bool"
moduleName = "XCreds"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/tperfitt/Documents/Projects/xcreds/XCredsLoginPlugIn/LoginWindow/SignInWindowController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "197"
endingLineNumber = "197"
offsetFromSymbolStart = "1512">
</Location>
<Location
uuid = "EF6F795C-F6EE-40F5-9005-04332F7BEF91 - f6f721ff691f5653"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "XCreds.SignInViewController.showResetUI() -&gt; Swift.Bool"
moduleName = "XCreds"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/tperfitt/Documents/Projects/xcreds/XCredsLoginPlugIn/LoginWindow/SignInWindowController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "197"
endingLineNumber = "197"
offsetFromSymbolStart = "1528">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "D1226924-CED7-4BAE-916B-6576F735917C"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/UpdatePasswordWindowController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "19"
endingLineNumber = "19"
landmarkName = "windowDidLoad()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B71CF784-5FF7-4C16-88D6-0A531A14A774"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCredsLoginPlugIn/LoginWindow/SignInWindowController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "183"
endingLineNumber = "183"
landmarkName = "showResetUI()"
startingLineNumber = "84"
endingLineNumber = "84"
landmarkName = "saveTokensToKeychain(creds:setACL:password:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<key>auth_mech_fixup.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>7</integer>
<integer>8</integer>
</dict>
<key>authrights.xcscheme_^#shared#^_</key>
<dict>
Expand All @@ -42,7 +42,7 @@
<key>test.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>8</integer>
<integer>7</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down

0 comments on commit d0b70c3

Please sign in to comment.