Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Remote Bolus OTP validation on Authy #19

Merged
merged 1 commit into from
May 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions NightscoutServiceKit/OTPManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public class OTPManager {

private var secretStore: OTPSecretStore
private var nowDateSource: () -> Date
Copy link
Author

@gestrich gestrich Apr 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix: Changing SHA512 -> SHA1
Also adding "Issuer" as a property for reuse.

let algorithm: Generator.Algorithm = .sha512
let algorithm: Generator.Algorithm = .sha1
let issuerName = "Loop"
var tokenPeriod: TimeInterval
var passwordDigitCount = 6
public static var defaultTokenPeriod: TimeInterval = 30
Expand Down Expand Up @@ -143,7 +144,7 @@ public class OTPManager {
}

let generator = Generator(factor: .timer(period: TimeInterval(self.tokenPeriod)), secret: secretKeyData, algorithm: algorithm, digits: passwordDigitCount)!
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use property and get rid of unnecessary string interpolation.

return Token(name: "\(secretKeyName)", issuer: "Loop", generator: generator)
return Token(name: secretKeyName, issuer: issuerName, generator: generator)
}

public func getLastPasswordsAscending(count: Int) -> [String] {
Expand Down Expand Up @@ -183,7 +184,7 @@ public class OTPManager {
let queryItems = [
URLQueryItem(name: "algorithm", value: algorithm.otpURLStringComponent()),
URLQueryItem(name: "digits", value: "\(passwordDigitCount)"),
URLQueryItem(name: "issuer", value: "Loop"),
URLQueryItem(name: "issuer", value: issuerName),
URLQueryItem(name: "period", value: "\(Int(tokenPeriod))"),
URLQueryItem(name: "secret", value: secretKey),
]
Expand Down