Skip to content

Commit

Permalink
Detect when no password was entered #17
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Nov 30, 2023
1 parent f41411c commit 7cf2837
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 11 deletions.
3 changes: 3 additions & 0 deletions XCreds/WebViewWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class WebViewWindowController: NSWindowController {
}
func tokensUpdated(tokens: Creds){
}
func showErrorMessageAndDeny(_ message:String){
}
}

extension WebViewWindowController: WKNavigationDelegate {
Expand Down Expand Up @@ -323,6 +325,7 @@ extension WebViewWindowController: OIDCLiteDelegate {
else {
TCSLogWithMark("----- password was not set")
NotificationCenter.default.post(name: Notification.Name("TCSTokensUpdated"), object: self, userInfo:[:])
self.showErrorMessageAndDeny("The password was not set. Please check settings and verify passwordless sign-in was not used.")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ class LoginWebViewWindowController: WebViewWindowController, DSQueryable {
})
}

override func showErrorMessageAndDeny(_ message:String){

delegate?.denyLogin(message:message)
return
}

override func tokensUpdated(tokens: Creds) {
//if we have tokens, that means that authentication was successful.
//we have to check the password here so we can prompt.
Expand Down
11 changes: 10 additions & 1 deletion XCredsLoginPlugIn/Mechanisms/XCredsLoginMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,16 @@ import Network
alert.window.level=window.level+1
}
alert.window.canBecomeVisibleWithoutLogin=true
alert.icon=NSImage(named: NSImage.Name("AppIcon"))
let allBundles = Bundle.allBundles
for currentBundle in allBundles {
TCSLogWithMark(currentBundle.bundlePath)
if currentBundle.bundlePath.contains("XCredsLoginPlugin") {
TCSLogWithMark("Found bundle")

alert.icon=currentBundle.image(forResource: NSImage.Name("icon_128x128"))
break
}
}
alert.runModal()

}
Expand Down
16 changes: 10 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
7611CEC0288B75140063A644 /* XCredsCreateUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7611CEBF288B75140063A644 /* XCredsCreateUser.swift */; };
7611CEC2288B96760063A644 /* XCredsEnableFDE.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7611CEC1288B96760063A644 /* XCredsEnableFDE.swift */; };
7613FDF7289E114F00340CCD /* loadpage.html in Resources */ = {isa = PBXBuildFile; fileRef = 7613FDF6289E114F00340CCD /* loadpage.html */; };
7614D03C2B181A5D006EAF36 /* icon_128x128.png in Resources */ = {isa = PBXBuildFile; fileRef = 7614D03B2B181A5D006EAF36 /* icon_128x128.png */; };
761B486928A34CC900C6A02B /* LoginProgressWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 761B486728A34CC900C6A02B /* LoginProgressWindowController.xib */; };
761B486A28A34CC900C6A02B /* LoginProgressWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761B486828A34CC900C6A02B /* LoginProgressWindowController.swift */; };
761B486C28A3575000C6A02B /* XCredsLoginDone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761B486B28A3575000C6A02B /* XCredsLoginDone.swift */; };
Expand Down Expand Up @@ -294,6 +295,7 @@
7611CEBF288B75140063A644 /* XCredsCreateUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCredsCreateUser.swift; sourceTree = "<group>"; };
7611CEC1288B96760063A644 /* XCredsEnableFDE.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCredsEnableFDE.swift; sourceTree = "<group>"; };
7613FDF6289E114F00340CCD /* loadpage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = loadpage.html; sourceTree = "<group>"; };
7614D03B2B181A5D006EAF36 /* icon_128x128.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = icon_128x128.png; path = XCreds/Assets.xcassets/AppIcon.appiconset/icon_128x128.png; sourceTree = "<group>"; };
761B486728A34CC900C6A02B /* LoginProgressWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LoginProgressWindowController.xib; path = XCredsLoginPlugIn/LoginProgressWindowController.xib; sourceTree = SOURCE_ROOT; };
761B486828A34CC900C6A02B /* LoginProgressWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LoginProgressWindowController.swift; path = XCredsLoginPlugIn/LoginProgressWindowController.swift; sourceTree = SOURCE_ROOT; };
761B486B28A3575000C6A02B /* XCredsLoginDone.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCredsLoginDone.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -654,6 +656,7 @@
76EE069127FD1D00009E0F3A = {
isa = PBXGroup;
children = (
7614D03B2B181A5D006EAF36 /* icon_128x128.png */,
7681FEC82A4CFEA200F91CD1 /* com.twocanoes.xcreds.plist */,
76C63A312A22872700810C53 /* History.md */,
760418CC2A1331710051411B /* NomadLogin */,
Expand Down Expand Up @@ -961,6 +964,7 @@
761B486928A34CC900C6A02B /* LoginProgressWindowController.xib in Resources */,
766CC43829D3AED2009BC526 /* errorpage.html in Resources */,
760418D12A1332210051411B /* SignIn.xib in Resources */,
7614D03C2B181A5D006EAF36 /* icon_128x128.png in Resources */,
76BEF7E4287202090013E2A1 /* RestartX.png in Resources */,
76D925D32894ADB4005C3245 /* Assets.xcassets in Resources */,
76BEF8012872A3030013E2A1 /* loginwindow.png in Resources */,
Expand Down Expand Up @@ -1249,7 +1253,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5275;
CURRENT_PROJECT_VERSION = 5291;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1287,7 +1291,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5275;
CURRENT_PROJECT_VERSION = 5291;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1407,7 +1411,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5275;
CURRENT_PROJECT_VERSION = 5291;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1444,7 +1448,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5275;
CURRENT_PROJECT_VERSION = 5291;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1594,7 +1598,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5275;
CURRENT_PROJECT_VERSION = 5291;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1635,7 +1639,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5275;
CURRENT_PROJECT_VERSION = 5291;
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 @@ -156,8 +156,8 @@
filePath = "XCredsLoginPlugIn/LoginWindow/LoginWebViewWindowController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "316"
endingLineNumber = "316"
startingLineNumber = "322"
endingLineNumber = "322"
landmarkName = "tokensUpdated(tokens:)"
landmarkType = "7">
</BreakpointContent>
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 7cf2837

Please sign in to comment.