mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
Replace the ListMFADevices stub with the virtual MFA device lifecycle: CreateVirtualMFADevice, ListVirtualMFADevices, DeleteVirtualMFADevice, EnableMFADevice, DeactivateMFADevice, ResyncMFADevice, ListMFADevices, and the device tag readers/writers. The seed is real rather than a placeholder. CreateVirtualMFADevice generates a 160-bit secret from SecureRandom and returns it as an RFC 4648 base32 string, and EnableMFADevice/ResyncMFADevice verify codes against it as RFC 6238 TOTP, so a caller that does not hold the seed cannot enable a device. The codes must be consecutive, as AWS asks for. Implemented on the JDK's own javax.crypto, with no new dependency. The TOTP arithmetic is the shared core.common.Totp primitive (#4814): CognitoTotp keeps its single-code window and attempt budget, and VirtualMfaCodes holds the consecutive-pair rule that is specific to IAM. Request shapes are validated against the wire model before the device is resolved, so a malformed SerialNumber is a ValidationError rather than a NoSuchEntity, and UserName is enforced as required on Enable and Resync. VirtualMFADeviceName gets its own validator because it is the one IAM name type with no documented maximum length, so borrowing the usual 1-to-128 name check would have rejected names AWS accepts. Device state also reaches the places that report on it: DeleteUser now returns DeleteConflict while a user still holds a device, GetAccountSummary counts devices and their assignments, and the credential report's mfa_active column is backed by real state instead of a constant. Documented as out of scope: QRCodePNG is not returned (it needs a QR encoder, and the otpauth URI it encodes is derivable from the seed that is returned), GetMFADevice takes only FIDO security key ARNs, hardware and FIDO devices are not modeled, MFA still has no effect on authorization because the aws:MultiFactorAuth* keys are never populated, and STS does not accept SerialNumber/TokenCode.