I am working on an IOS application coding in SWIFT 4 and I am using the framework ADAL in order to authenticate the users. I set up the athentication and everything goes well until the log out. When I log out a user from the application, the application deletes the cookie. When trying to issue a log out and log in as a different user Azure AD is still seeing the previous cookie.
The code of the signout function below :
@IBAction func signoutButton(_ sender: Any) {
displaySelectionController.isHidden = true
self.signoutButton.isEnabled = false
self.signoutButton.backgroundColor = #colorLiteral(red: 0.7018831372, green: 0.7020055652, blue: 0.7018753886, alpha: 1)
connectedLabel.isHidden = true
connectedTextInfo.isHidden = true
callGraphButton.isHidden = false
displaySelectionController.isHidden = true
let request = NSMutableURLRequest(url: NSURL(string: "https://login.microsoft.com/logout")! as URL)
request.httpMethod = "GET"
guard let account = currentAccount()?.userInformation?.userId else {
self.updateLogging(text: "Didn't find a logged in account in the cache.")
return
}
ADKeychainTokenCache.defaultKeychain().removeAll(forUserId: account, clientId: kClientID, error: nil)
let cookieJar = HTTPCookieStorage.shared
guard let cookies = cookieJar.cookies else { return }
let cookiesArr = Array(cookies)
for cookie: HTTPCookie in cookiesArr {
if (cookie.name == "SignInStateCookie" || cookie.name == "ESTSAUTHPERSISTENT" || cookie.name == "ESTSAUTHLIGHT" || cookie.name == "ESTSAUTH" || cookie.name == "ESTSSC") {
cookieJar.deleteCookie(cookie)
print(" COOKIE DELETED")
}
}
self.updateLogging(text: "Removed account for: \(account)" )
}
SFSafariViewControllerin your logout process? - Paulw11