Skip to content

Commit

Permalink
fixed fade; cleaned up user mappings for weird characters
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Jun 21, 2023
1 parent 0d14279 commit c630495
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 153 deletions.
2 changes: 1 addition & 1 deletion NomadLogin/UI/SignIn.xib
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<constraints>
<constraint firstAttribute="width" constant="200" id="erX-h9-hpb"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" placeholderString="Username@domain" usesSingleLineMode="YES" bezelStyle="round" id="uli-8f-B8b">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" placeholderString="Name" usesSingleLineMode="YES" bezelStyle="round" id="uli-8f-B8b">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down
2 changes: 1 addition & 1 deletion NomadLogin/UI/SignInWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SignInWindowController: NSWindowController, DSQueryable {

if setupDone == false {
setupDone=true
self.localOnlyCheckBox.isHidden = !self.domainName.isEmpty
self.localOnlyCheckBox.isHidden = self.domainName.isEmpty

TCSLogWithMark("Configure login window")
loginAppearance()
Expand Down
40 changes: 40 additions & 0 deletions XCreds/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var window: NSWindow!
var mainController:MainController?
var wifiWindowController:WifiWindowController?
var screenIsLocked=true
var isDisplayAsleep=true
var waitForScreenToWake=false
func applicationDidFinishLaunching(_ aNotification: Notification) {

let infoPlist = Bundle.main.infoDictionary
Expand All @@ -25,6 +28,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {


DistributedNotificationCenter.default().addObserver(self, selector: #selector(screenLocked(_:)), name:NSNotification.Name("com.apple.screenIsLocked") , object: nil)

DistributedNotificationCenter.default().addObserver(self, selector: #selector(screenUnlocked(_:)), name:NSNotification.Name("com.apple.screenIsUnlocked") , object: nil)

NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(screenDidSleep(_:)), name:NSWorkspace.screensDidSleepNotification , object: nil)

NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(screenDidWake(_:)), name:NSWorkspace.screensDidWakeNotification , object: nil)

mainController = MainController.init()
mainController?.run()
mainMenu.statusBarItem.menu = mainMenu.mainMenu
Expand All @@ -38,11 +48,41 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
@objc func screenUnlocked(_ sender:Any) {
TCSLogWithMark()
screenIsLocked=false

}
@objc func screenLocked(_ sender:Any) {
TCSLogWithMark()
screenIsLocked=true
if isDisplayAsleep==true{

waitForScreenToWake=true
}
else {
waitForScreenToWake=false
switchToLoginWindow() }

}
@objc func screenDidSleep(_ sender:Any) {
TCSLogWithMark()
isDisplayAsleep=true
}
@objc func screenDidWake(_ sender:Any) {
TCSLogWithMark()
isDisplayAsleep=false

if waitForScreenToWake==true {
waitForScreenToWake=false
switchToLoginWindow()
}
}
func switchToLoginWindow() {
if DefaultsOverride.standardOverride.bool(forKey: PrefKeys.shouldSwitchToLoginWindowWhenLocked.rawValue)==true{
TCSLoginWindowUtilities().switchToLoginWindow(self)
}

}


Expand Down
2 changes: 1 addition & 1 deletion XCreds/TCSLoginWindowUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ -(void)switchToLoginWindow:(id)sender{
id login_window = [SAConnection remoteObjectProxy];


[login_window SACSwitchToLoginWindow:^(int) {
[login_window SACSwitchToLoginWindow:^(int val) {

}];

Expand Down
14 changes: 7 additions & 7 deletions XCredsLoginPlugIn/LoginWindow/LocalUsersViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="8Nq-qD-r0P"/>
</imageView>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" verticalCompressionResistancePriority="250" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gwU-ij-829" userLabel="login stack">
<rect key="frame" x="140" y="97" width="200" height="76"/>
<rect key="frame" x="140" y="95" width="200" height="80"/>
<subviews>
<textField verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hAg-pc-UUB">
<rect key="frame" x="0.0" y="54" width="200" height="22"/>
<rect key="frame" x="0.0" y="58" width="200" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="DC3-pa-LqT"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" placeholderString="Username@domain" usesSingleLineMode="YES" bezelStyle="round" id="IEP-jE-4l7">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" placeholderString="Name" usesSingleLineMode="YES" bezelStyle="round" id="IEP-jE-4l7">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -50,7 +50,7 @@
</connections>
</textField>
<secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nX9-ug-iIi">
<rect key="frame" x="0.0" y="24" width="200" height="22"/>
<rect key="frame" x="0.0" y="28" width="200" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="QA1-E9-AfT"/>
</constraints>
Expand All @@ -67,8 +67,8 @@
</connections>
</secureTextField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JO2-an-6VU">
<rect key="frame" x="-2" y="-1" width="158" height="18"/>
<buttonCell key="cell" type="check" title="Offline Authentication" bezelStyle="regularSquare" imagePosition="left" inset="2" id="vmH-hk-adz">
<rect key="frame" x="-3" y="-4" width="178" height="27"/>
<buttonCell key="cell" type="check" title="Offline Authentication" bezelStyle="regularSquare" imagePosition="left" borderStyle="border" inset="2" id="vmH-hk-adz">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
Expand All @@ -94,7 +94,7 @@
</buttonCell>
</button>
<button verticalHuggingPriority="750" verticalCompressionResistancePriority="100" translatesAutoresizingMaskIntoConstraints="NO" id="gPL-7i-JQY">
<rect key="frame" x="347" y="119" width="15" height="27"/>
<rect key="frame" x="347" y="117" width="15" height="27"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="PON-vz-fED"/>
<constraint firstAttribute="width" constant="15" id="sjZ-4g-8aq"/>
Expand Down
24 changes: 18 additions & 6 deletions XCredsLoginPlugIn/LoginWindow/LoginWebViewWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ class LoginWebViewWindowController: WebViewWindowController {
context.duration = 1.0
context.allowsImplicitAnimation = true
self.webView?.animator().alphaValue = 0.0
// self.webView?.animator().frame=NSMakeRect(self.webView.frame.origin.x+self.webView.frame.size.width/2, self.webView.frame.origin.y,0,self.webView.frame.size.height)
}, completionHandler: {
self.webView?.alphaValue = 0.0
self.window?.close()
self.webView.removeFromSuperview()
// self.window?.close()


})
Expand Down Expand Up @@ -190,6 +190,10 @@ class LoginWebViewWindowController: WebViewWindowController {
delegate.denyLogin()
return
}
if let decodedTokenString = String(data: data, encoding: .utf8) {
TCSLogWithMark("IDToken:\(decodedTokenString)")

}
let decoder = JSONDecoder()
var idTokenObject:IDToken
do {
Expand All @@ -204,16 +208,17 @@ class LoginWebViewWindowController: WebViewWindowController {

}

let idTokenInfo = jwtDecode(value: idToken) //dictionary for mappnigs
let idTokenInfo = jwtDecode(value: idToken) //dictionary for mapping

// username static map
if let defaultsUsername = defaultsUsername {
username = defaultsUsername
}
else if let idTokenInfo = idTokenInfo, let mapKey = DefaultsOverride.standardOverride.object(forKey: "map_username") as? String, mapKey.count>0, let mapValue = idTokenInfo[mapKey] as? String {
else if let idTokenInfo = idTokenInfo, let mapKey = DefaultsOverride.standardOverride.object(forKey: "map_username") as? String, mapKey.count>0, let mapValue = idTokenInfo[mapKey] as? String, let leftSide = mapValue.components(separatedBy: "@").first{

username = leftSide.replacingOccurrences(of: " ", with: "_").stripped
TCSLogWithMark("mapped username found: \(mapValue) clean version:\(username)")

username = mapValue
TCSLogWithMark("mapped username found: \(username)")

}
else {
Expand Down Expand Up @@ -435,3 +440,10 @@ class LoginWebViewWindowController: WebViewWindowController {
}


extension String {

var stripped: String {
let okayChars = Set("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLKMNOPQRSTUVWXYZ1234567890+-._")
return self.filter {okayChars.contains($0) }
}
}
4 changes: 4 additions & 0 deletions XCredsLoginPlugIn/LoginWindow/LoginWindowControls.xib
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
<string key="title">Switch
Login Window</string>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
</buttonCell>
<color key="contentTintColor" red="0.99999600649999998" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4153;
CURRENT_PROJECT_VERSION = 4165;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1270,7 +1270,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4153;
CURRENT_PROJECT_VERSION = 4165;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1389,7 +1389,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4153;
CURRENT_PROJECT_VERSION = 4165;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1425,7 +1425,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4153;
CURRENT_PROJECT_VERSION = 4165;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1574,7 +1574,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4153;
CURRENT_PROJECT_VERSION = 4165;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1610,7 +1610,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4153;
CURRENT_PROJECT_VERSION = 4165;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
Binary file not shown.

0 comments on commit c630495

Please sign in to comment.