Skip to content

Commit

Permalink
tweaked create user
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Jul 24, 2022
1 parent 2bd3cb8 commit 4bfdd10
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 26 deletions.
33 changes: 21 additions & 12 deletions XCredsLoginPlugIn/LoginWindow/LoginWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ class LoginWebViewController: WebViewController {
delegate.denyLogin()
return
}

if isLocal == false {
TCSLogWithMark("User is not on system. for now, just abort")
delegate.denyLogin()
return
}
//
// if isLocal == false {
// TCSLogWithMark("User is not on system. for now, just abort")
// delegate.denyLogin()
// return
// }

let hasHome = try? PasswordUtils.doesUserHomeExist(username)
guard let hasHome = hasHome else {
Expand All @@ -170,11 +170,11 @@ class LoginWebViewController: WebViewController {
return
}

if hasHome == false {
TCSLogWithMark("User has no home. for now, just abort")
delegate.denyLogin()
return
}
// if hasHome == false {
// TCSLogWithMark("User has no home. for now, just abort")
// delegate.denyLogin()
// return
// }



Expand Down Expand Up @@ -241,9 +241,18 @@ class LoginWebViewController: WebViewController {
}

}
TCSLogWithMark("updating username, password, and tokens")
TCSLogWithMark("updating username:\(username), password, and tokens")
delegate.setContextString(type: kAuthorizationEnvironmentUsername, value: username)
delegate.setContextString(type: kAuthorizationEnvironmentPassword, value: tokens.password)
delegate.setHint(type: .user, hint: username)
delegate.setHint(type: .pass, hint: tokens.password)
// setHint(type: .noMADFirst, hint: user.firstName)
// setHint(type: .noMADLast, hint: user.lastName)
// setHint(type: .noMADDomain, hint: domainName)
// setHint(type: .noMADGroups, hint: user.groups)
delegate.setHint(type: .fullName, hint: idTokenObject.unique_name ?? username)
delegate.setHint(type: .firstName, hint: idTokenObject.given_name ?? "")
delegate.setHint(type: .lastName, hint: idTokenObject.family_name ?? "")

delegate.setHint(type: .tokens, hint: [tokens.idToken,tokens.refreshToken,tokens.accessToken])

Expand Down
18 changes: 13 additions & 5 deletions XCredsLoginPlugIn/Mechanisms/XCredsBaseMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,20 @@ protocol XCredsMechanismProtocol {
let defaultsDict = NSDictionary(contentsOfFile: defaultsPath)
UserDefaults.standard.register(defaults: defaultsDict as! [String : Any])
}
let infoPlist = Bundle.main.infoDictionary

if let infoPlist = infoPlist, let build = infoPlist["CFBundleVersion"] {
TCSLogWithMark("Build \(build)")
let allBundles = Bundle.allBundles

for currentBundle in allBundles {
if currentBundle.bundlePath.contains("XCreds") {
let infoPlist = currentBundle.infoDictionary
if let infoPlist = infoPlist, let build = infoPlist["CFBundleVersion"] {
TCSLogWithMark("-------------------------------------")
TCSLogWithMark("XCreds Login Build Number: \(build)")
TCSLogWithMark("-------------------------------------")
break
}

}
}


Expand Down Expand Up @@ -83,7 +92,6 @@ protocol XCredsMechanismProtocol {

return nil
}
TCSLogWithMark("Computed user accessed")
return userName
}
}
Expand Down Expand Up @@ -178,7 +186,7 @@ protocol XCredsMechanismProtocol {
var err: OSStatus = noErr
err = mechCallbacks.GetHintValue((mech?.fEngine)!, type.rawValue, &value)
if err != errSecSuccess {
TCSLogWithMark("Couldn't retrieve hint value: %{public}@")
TCSLogWithMark("Couldn't retrieve hint value: \(type.rawValue)")
return nil
}
let outputdata = Data.init(bytes: value!.pointee.data!, count: value!.pointee.length)
Expand Down
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/XCredsLoginPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ - (OSStatus)MechanismCreate:(AuthorizationPluginRef)inPlugin
mechanism->fLoginWindow = (strcmp(mechanismId, "LoginWindow") == 0);
mechanism->fPowerControl = (strcmp(mechanismId, "PowerControl") == 0);
mechanism->fKeychainAdd = (strcmp(mechanismId, "KeychainAdd") == 0);
mechanism->fKeychainAdd = (strcmp(mechanismId, "CreateUser") == 0);
mechanism->fCreateUser = (strcmp(mechanismId, "CreateUser") == 0);
*outMechanism = mechanism;

return errSecSuccess;
Expand Down
8 changes: 7 additions & 1 deletion app_to_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ ssh -J [email protected] [email protected] rm -rf "/Applications/XCreds.app"

scp -r -J [email protected] "${BUILD_ROOT}"/Release/XCreds.app [email protected]:/Applications/

#ssh -J [email protected] [email protected] reboot || exit 0
#ssh -J [email protected] [email protected] reboot || exit 0

ssh -J [email protected] [email protected] /Applications/XCreds.app/Contents/Resources/xcreds_login.sh -r

ssh -J [email protected] [email protected] /Applications/XCreds.app/Contents/Resources/xcreds_login.sh -i

ssh -J [email protected] [email protected] killall -9 SecurityAgent || echo "unable to kill"
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3011;
CURRENT_PROJECT_VERSION = 3022;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -890,7 +890,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3011;
CURRENT_PROJECT_VERSION = 3022;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -948,7 +948,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3011;
CURRENT_PROJECT_VERSION = 3022;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -978,7 +978,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3011;
CURRENT_PROJECT_VERSION = 3022;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1121,7 +1121,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3011;
CURRENT_PROJECT_VERSION = 3022;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1150,7 +1150,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3011;
CURRENT_PROJECT_VERSION = 3022;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
Binary file not shown.
21 changes: 20 additions & 1 deletion xCreds.xcodeproj/xcshareddata/xcschemes/Send To Test.xcscheme
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
version = "1.3">
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "cd &quot;${PROJECT_DIR}&quot;&#10;&#10;#/usr/bin/agvtool bump&#10;"
shellToInvoke = "/bin/sh">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "766F4C4C2883B88F0021F548"
BuildableName = "Send To Test"
BlueprintName = "Send To Test"
ReferencedContainer = "container:XCreds.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down

0 comments on commit 4bfdd10

Please sign in to comment.