Skip to content

Commit

Permalink
Support separate client ID and secret for ropg
Browse files Browse the repository at this point in the history
Supporting a different client ID and secret allow for webview
login windows which support MFA and password verification with ropg.
Without a separate ID and secret one would be force to use a native
login window without MFA support for login, which doesn't support MFA or
the setup of an MFA device.
  • Loading branch information
hurricanehrndz committed Jan 15, 2024
1 parent 88eaaf4 commit 4e00816
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions XCreds/PrefKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Foundation
enum PrefKeys: String {
case clientID, clientSecret, password="xcreds local password",discoveryURL, redirectURI, scopes, accessToken, idToken, refreshToken, tokenEndpoint, expirationDate, invalidToken, refreshRateHours,refreshRateMinutes, showDebug, verifyPassword, shouldShowQuitMenu, shouldShowPreferencesOnStart, shouldSetGoogleAccessTypeToOffline, passwordChangeURL, shouldShowAboutMenu, username, idpHostName, passwordElementID, shouldFindPasswordElement, shouldShowVersionInfo, shouldShowSupportStatus,shouldShowConfigureWifiButton,shouldShowMacLoginButton, loginWindowBackgroundImageURL, shouldShowCloudLoginByDefault, shouldPreferLocalLoginInsteadOfCloudLogin, idpHostNames,autoRefreshLoginTimer, loginWindowWidth, loginWindowHeight, shouldShowRefreshBanner, shouldSwitchToLoginWindowWhenLocked,accounts = "Accounts",
windowSignIn = "WindowSignIn", settingsOverrideScriptPath, localAdminUserName, localAdminPassword, usernamePlaceholder, passwordPlaceholder, shouldShowLocalOnlyCheckbox, shouldShowTokenUpdateStatus, shouldDetectNetworkToDetermineLoginWindow, showLoginWindowDelaySeconds, shouldPromptForMigration, shouldAllowKeyComboForMacLoginWindow, aliasName,claimsToAddToLocalUserAccount, loadPageTitle, loadPageInfo,shouldPromptForADPasswordChange, hideIfPathExists, allowedUsersArray, allowUsersClaim
case ropgClientID
case ropgClientSecret
case shouldVerifyPasswordWithRopg
case shouldUpdatePasswordWithWebview
case shouldUseROPGForOIDCLogin
Expand Down
16 changes: 14 additions & 2 deletions XCreds/TokenManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,38 @@ class TokenManager: OIDCLiteDelegate,DSQueryable {
var scopes: [String]?
var additionalParameters:[String:String]? = nil
var clientSecret:String?
var clientID:String?

if let oidcPrivate = oidcLocal {
oidcPrivate.getEndpoints()

return oidcPrivate
}
if let clientSecretRaw = DefaultsOverride.standardOverride.string(forKey: PrefKeys.clientSecret.rawValue),
let clientSecretRaw = DefaultsOverride.standardOverride.string(forKey: PrefKeys.ropgClientSecret.rawValue) != nil ? DefaultsOverride.standardOverride.string(forKey: PrefKeys.ropgClientSecret.rawValue) : DefaultsOverride.standardOverride.string(forKey: PrefKeys.clientSecret.rawValue)

if let clientSecretRaw = clientSecretRaw,
clientSecretRaw != "" {
clientSecret = clientSecretRaw
}

let clientIDRaw = DefaultsOverride.standardOverride.string(forKey: PrefKeys.ropgClientID.rawValue) != nil ? DefaultsOverride.standardOverride.string(forKey: PrefKeys.ropgClientID.rawValue) : DefaultsOverride.standardOverride.string(forKey: PrefKeys.clientID.rawValue)

if let clientIDRaw = clientIDRaw,
clientSecretRaw != "" {
clientID = clientIDRaw
}

if let scopesRaw = DefaultsOverride.standardOverride.string(forKey: PrefKeys.scopes.rawValue) {
scopes = scopesRaw.components(separatedBy: " ")
}

//
if DefaultsOverride.standardOverride.bool(forKey: PrefKeys.shouldSetGoogleAccessTypeToOffline.rawValue) == true {

additionalParameters = ["access_type":"offline"]
}

let oidcLite = OIDCLite(discoveryURL: DefaultsOverride.standardOverride.string(forKey: PrefKeys.discoveryURL.rawValue) ?? "NONE", clientID: DefaultsOverride.standardOverride.string(forKey: PrefKeys.clientID.rawValue) ?? "NONE", clientSecret: clientSecret, redirectURI: DefaultsOverride.standardOverride.string(forKey: PrefKeys.redirectURI.rawValue), scopes: scopes, additionalParameters:additionalParameters )
let oidcLite = OIDCLite(discoveryURL: DefaultsOverride.standardOverride.string(forKey: PrefKeys.discoveryURL.rawValue) ?? "NONE", clientID: clientID ?? "NONE", clientSecret: clientSecret ?? "NONE", redirectURI: DefaultsOverride.standardOverride.string(forKey: PrefKeys.redirectURI.rawValue), scopes: scopes, additionalParameters:additionalParameters )
oidcLite.getEndpoints()
oidcLocal = oidcLite
oidcLite.delegate=self
Expand Down

0 comments on commit 4e00816

Please sign in to comment.