Skip to content

Commit

Permalink
Fix digits not being optional
Browse files Browse the repository at this point in the history
Fixes #77 (PR #78).

* * *

According to the
https://github.com/google/google-authenticator/wiki/Key-Uri-Format#digits,
`digits` parameter should be **optional**. It is not, e.g. after using
this URI:

```
otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example
```

The application raises this error:

```
[2023-12-22 18:36:00,369] DEBUG:otp:352: 1 validation error for Uri
schema_ -> TOTPUriSchema -> parameters -> digits
  field required (type=value_error.missing)
Usage: otp add uri [OPTIONS] ALIAS
Try 'otp add uri -h' for help.

Error: invalid URI
```
  • Loading branch information
Toreno96 committed Dec 28, 2023
1 parent 961df32 commit 3f7df82
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion onetimepass/otpauth/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BaseUriParameters(BaseModel, extra=Extra.forbid):
hash_algorithm: Literal["SHA1", "SHA256", "SHA512"] = Field(
"SHA1", alias="algorithm"
)
digits: int
digits: int = 6

@validator("issuer")
def issuer_must_match_pattern(cls, v):
Expand Down

0 comments on commit 3f7df82

Please sign in to comment.