Skip to content

Commit

Permalink
cleaned up ropg login code
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Dec 27, 2023
1 parent 32ad7b3 commit e9b1268
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 47 deletions.
17 changes: 2 additions & 15 deletions XCreds/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,8 @@
import Cocoa

@main
class AppDelegate: NSObject, NSApplicationDelegate, DSQueryable, TokenManagerFeedbackDelegate {
func tokenError(_ err: String) {

}

func credentialsUpdated(_ credentials: Creds) {

}


class AppDelegate: NSObject, NSApplicationDelegate, DSQueryable {

@IBOutlet weak var loginPasswordWindow: NSWindow!
@IBOutlet var window: NSWindow!
var mainController:MainController?
Expand All @@ -32,11 +24,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, DSQueryable, TokenManagerFee
TCSLogWithMark("Build \(build)")

}
let tm = TokenManager()
tm.feedbackDelegate=self
tm.oidc().requestTokenWithROPG(ropgUsername:"fred@twocanoes.com", ropgPassword: "ChairBook1!")
//
//
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)
Expand Down
2 changes: 1 addition & 1 deletion XCreds/MainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class MainController: NSObject, NoMADUserSessionDelegate, TokenManagerFeedbackDe


func tokenError(_ err: String) {
print(err)
TCSLogWithMark("Token error: \(err)")
}

func NoMADAuthenticationSucceded() {
Expand Down
7 changes: 3 additions & 4 deletions XCreds/TokenManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ protocol TokenManagerFeedbackDelegate {
}
class TokenManager: OIDCLiteDelegate,DSQueryable {
func authFailure(message: String) {

TCSLogWithMark("authFailure: \(message)")
feedbackDelegate?.tokenError(message)
}

struct UserAccountInfo {
Expand Down Expand Up @@ -188,7 +189,7 @@ class TokenManager: OIDCLiteDelegate,DSQueryable {
completion(.error("no username for oidc config"))
return
}
oidc().requestTokenWithROPG(ropgUsername: username, ropgPassword: keychainPassword)
oidc().requestTokenWithROPG(username: username, password: keychainPassword)

}
else if let refreshAccountAndToken = refreshAccountAndToken, let refreshToken = refreshAccountAndToken.1 {
Expand All @@ -208,8 +209,6 @@ class TokenManager: OIDCLiteDelegate,DSQueryable {
guard let idToken = credentials.idToken else {
TCSLogErrorWithMark("invalid idToken")
throw ProcessTokenResult.error("invalid idToken")
// mechanismDelegate.denyLogin(message:"The identity token is invalid")
// return
}

let array = idToken.components(separatedBy: ".")
Expand Down
2 changes: 1 addition & 1 deletion XCreds/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import OIDCLite

class WebViewController: NSViewController, TokenManagerFeedbackDelegate {
func credentialsUpdated(_ credentials: Creds) {

TCSLogWithMark()
}

@IBOutlet weak var refreshTitleTextField: NSTextField?
Expand Down
6 changes: 4 additions & 2 deletions XCredsLoginPlugIn/LoginWindow/SignInWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ let checkADLog = OSLog(subsystem: "menu.nomad.login.ad", category: "CheckADMech"
@objc class SignInViewController: NSViewController, DSQueryable, TokenManagerFeedbackDelegate {

func tokenError(_ err:String){

TCSLogWithMark("Token error: \(err)")
authFail()
}

func credentialsUpdated(_ credentials:Creds){
TCSLogWithMark()
if mechanismDelegate?.setupHints(fromCredentials: credentials, password: passString ) == false {
TCSLogWithMark("error setting up hints")
authFail()
}

}
Expand Down Expand Up @@ -260,7 +262,7 @@ let checkADLog = OSLog(subsystem: "menu.nomad.login.ad", category: "CheckADMech"
tokenManager.feedbackDelegate=self

shortName = strippedUsername
tokenManager.oidc().requestTokenWithROPG(ropgUsername: strippedUsername, ropgPassword: passString)
tokenManager.oidc().requestTokenWithROPG(username: strippedUsername, password: passString)
return


Expand Down
5 changes: 3 additions & 2 deletions XCredsLoginPlugIn/Mechanisms/XCredsBaseMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ import OpenDirectory
return true
}
catch TokenManager.ProcessTokenResult.error(let msg){
denyLogin(message: msg)
TCSLogWithMark("invalid idToken:\(msg)")
denyLogin(message: nil)
return false
}
catch {
Expand Down Expand Up @@ -297,7 +298,7 @@ import OpenDirectory
func denyLogin(message: String?) {
TCSLogErrorWithMark("***************** DENYING LOGIN ********************");

if let message = message {
if let message = message {
setStickyContextString(type: "ErrorMessage", value: message)
}

Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6141;
CURRENT_PROJECT_VERSION = 6163;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1447,7 +1447,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6141;
CURRENT_PROJECT_VERSION = 6163;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1568,7 +1568,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6141;
CURRENT_PROJECT_VERSION = 6163;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1605,7 +1605,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6141;
CURRENT_PROJECT_VERSION = 6163;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1755,7 +1755,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6141;
CURRENT_PROJECT_VERSION = 6163;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1797,7 +1797,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6141;
CURRENT_PROJECT_VERSION = 6163;
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 @@ -4,22 +4,6 @@
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E1EA521E-AF06-45D9-98E9-8460A2C7CC2C"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/AppDelegate.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "17"
endingLineNumber = "17"
landmarkName = "credentialsUpdated(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
Expand Down

0 comments on commit e9b1268

Please sign in to comment.