Skip to content

Commit

Permalink
implemented feature request: localad/kebereros support for saving gro…
Browse files Browse the repository at this point in the history
…ups to prefs #125
  • Loading branch information
twocanoes committed Dec 11, 2023
1 parent 72ffc3f commit 1d3e2be
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 56 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 3.3 (5330) OAuth Settings</string>
<string>XCreds 3.3 (5565) 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
23 changes: 4 additions & 19 deletions XCredsLoginPlugIn/LoginWindow/LoginWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ class LoginWebViewController: WebViewController, DSQueryable {
mechanism.denyLogin(message:errorMessage)
return
}

}


if username == nil {
// username static map
if let defaultsUsername = defaultsUsername {
Expand Down Expand Up @@ -287,8 +284,6 @@ class LoginWebViewController: WebViewController, DSQueryable {
return
}
}


TCSLogWithMark("passing username:\(username), password, and tokens")
TCSLogWithMark("setting kAuthorizationEnvironmentUsername")

Expand All @@ -309,25 +304,15 @@ class LoginWebViewController: WebViewController, DSQueryable {
// NotificationCenter.default.removeObserver(resolutionObserver)
// }
//
DispatchQueue.main.async{
TCSLogWithMark("calling allowLogin")

self.mechanism?.allowLogin()

if let controller = self.view.window?.windowController as? MainLoginWindowController {
controller.loginTransition {
TCSLogWithMark("calling allowLogin")

}
if let controller = self.view.window?.windowController as? MainLoginWindowController {
controller.loginTransition {
self.mechanism?.allowLogin()
}

}


}

}


extension String {

var stripped: String {
Expand Down
60 changes: 32 additions & 28 deletions XCredsLoginPlugIn/LoginWindow/MainLoginWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,38 +117,42 @@ class MainLoginWindowController: NSWindowController,NSWindowDelegate {
}

func loginTransition( completion:@escaping ()->Void) {
TCSLogWithMark()
let screenRect = NSScreen.screens[0].frame
let progressIndicator=NSProgressIndicator.init(frame: NSMakeRect(screenRect.width/2-16 , 3*screenRect.height/4-16,32, 32))
progressIndicator.style = .spinning
progressIndicator.startAnimation(self)
self.window?.contentView?.addSubview(progressIndicator)

if let resolutionObserver = resolutionObserver {
NotificationCenter.default.removeObserver(resolutionObserver)
}
if let networkChangeObserver = networkChangeObserver {
NotificationCenter.default.removeObserver(networkChangeObserver)
}
DispatchQueue.main.async {

NSAnimationContext.runAnimationGroup({ (context) in
context.duration = 1.0
context.allowsImplicitAnimation = true
self.centerView?.animator().alphaValue = 0.0
let origin = self.controlsViewController?.view.frame.origin
let size = self.controlsViewController?.view.frame.size

if let origin = origin, let size = size {
self.controlsViewController?.view.animator().setFrameOrigin(NSMakePoint(origin.x, origin.y-(2*size.height)))
TCSLogWithMark()
let screenRect = NSScreen.screens[0].frame
let progressIndicator=NSProgressIndicator.init(frame: NSMakeRect(screenRect.width/2-16 , 3*screenRect.height/4-16,32, 32))
progressIndicator.style = .spinning
progressIndicator.startAnimation(self)
self.window?.contentView?.addSubview(progressIndicator)

if let resolutionObserver = self.resolutionObserver {
NotificationCenter.default.removeObserver(resolutionObserver)
}
if let networkChangeObserver = self.networkChangeObserver {
NotificationCenter.default.removeObserver(networkChangeObserver)
}
}, completionHandler: {
self.centerView?.alphaValue = 0.0
self.controlsViewController?.view.animator().alphaValue=0.0

self.centerView?.removeFromSuperview()
self.controlsViewController?.view.removeFromSuperview()
completion()
})
NSAnimationContext.runAnimationGroup({ (context) in
context.duration = 1.0
context.allowsImplicitAnimation = true
self.centerView?.animator().alphaValue = 0.0
let origin = self.controlsViewController?.view.frame.origin
let size = self.controlsViewController?.view.frame.size

if let origin = origin, let size = size {
self.controlsViewController?.view.animator().setFrameOrigin(NSMakePoint(origin.x, origin.y-(2*size.height)))
}
}, completionHandler: {
self.centerView?.alphaValue = 0.0
self.controlsViewController?.view.animator().alphaValue=0.0

self.centerView?.removeFromSuperview()
self.controlsViewController?.view.removeFromSuperview()
completion()
})
}

}

Expand Down
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/LoginWindow/SignInWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ extension SignInViewController: NoMADUserSessionDelegate {
TCSLogWithMark("Groups:\(user.groups)")
var allowedLogin = true

TCSLogWithMark("Checking for DenyLogin groups")
TCSLogWithMark("Checking for DenyLogin groupsChecking for DenyLogin groups")

if let allowedGroups = getManagedPreference(key: .DenyLoginUnlessGroupMember) as? [String] {
TCSLogErrorWithMark("Found a DenyLoginUnlessGroupMember key value: \(allowedGroups.debugDescription)")
Expand Down
10 changes: 10 additions & 0 deletions XCredsLoginPlugIn/Mechanisms/XCredsCreateUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ class XCredsCreateUser: XCredsBaseMechanism, DSQueryable {
TCSLogWithMark("updating claims in DS")
let claimsToDSArray = (DefaultsOverride.standardOverride.array(forKey: PrefKeys.claimsToAddToLocalUserAccount.rawValue) ?? []) as? [String]

TCSLogWithMark("Checking if member of group")
let userGroups = getHint(type: .groups) as? [String]

if let userGroups = userGroups, userGroups.count>0 {
TCSLogWithMark("is a member of \(userGroups.count) groups. Adding to OD record.")
let groupsString = userGroups.joined(separator: ",")
try? records.first?.setValue(groupsString, forAttribute: "dsAttrTypeNative:_xcreds_groups")

}

let tokenArray = getHint(type: .tokens) as? Array<String>

if let tokenArray = tokenArray , tokenArray.count>0{
Expand Down
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/Mechanisms/XCredsLoginMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ import Network
override func allowLogin() {
TCSLogWithMark("Allowing Login")

if loginWebViewController != nil {
if loginWebViewController != nil || signInViewController != nil {
TCSLogWithMark("Dismissing loginWindowWindowController")
mainLoginWindowController.loginTransition {
super.allowLogin()
Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5564;
CURRENT_PROJECT_VERSION = 5570;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1331,7 +1331,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5564;
CURRENT_PROJECT_VERSION = 5570;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1451,7 +1451,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5564;
CURRENT_PROJECT_VERSION = 5570;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1488,7 +1488,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5564;
CURRENT_PROJECT_VERSION = 5570;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1638,7 +1638,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5564;
CURRENT_PROJECT_VERSION = 5570;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1679,7 +1679,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5564;
CURRENT_PROJECT_VERSION = 5570;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
Binary file not shown.

0 comments on commit 1d3e2be

Please sign in to comment.