feat: add JWT Support to MDM and refacture (MESSENGER-6162)

This commit is contained in:
Frank Rotermund
2024-07-25 12:51:43 +02:00
parent bb60e8f85d
commit dc6c9f8fc4
9 changed files with 53 additions and 88 deletions

View File

@@ -226,37 +226,15 @@ struct AuthenticationServerSelectionScreen: View {
}
private func isHomeserverAddressValid(_ homeserverAddress: String) async -> Bool {
// bwi #6162 a homeserveraddress is valid when there is either
// a) no homeserver protection (bwm)
// b) tokenized protection and there is a valid token
// c) hashed protection and there is a valid hash (this will be disabled soon)
// d) b) && c) can be combined for now
if !BWIBuildSettings.shared.bwiEnableTokenizedLoginProtection && !BWIBuildSettings.shared.bwiEnableLoginProtection {
return true
}
var validHomeserver = false
if BWIBuildSettings.shared.bwiEnableTokenizedLoginProtection {
let tokenVerificator = ServerTokenVerificator()
let token = await tokenVerificator.fetchToken(baseURL: homeserverAddress)
if let token = token {
validHomeserver = tokenVerificator.verifyToken(baseURL: homeserverAddress, token: token)
}
}
if BWIBuildSettings.shared.bwiEnableLoginProtection && !validHomeserver {
if BWIBuildSettings.shared.bwiEnableLoginProtection || BWIBuildSettings.shared.bwiEnableTokenizedLoginProtection {
let protectionService = LoginProtectionService()
protectionService.hashes = BWIBuildSettings.shared.bwiHashes
validHomeserver = protectionService.isValid(homeserverAddress)
return await protectionService.isValid(homeserverAddress)
}
return validHomeserver
return true
}
/// bwi: jump directly into the iOS settings app to allow camera access