Skip to content

Commit

Permalink
Fix regression after renaming *algorithm variables
Browse files Browse the repository at this point in the history
Fixes #75 (PR #76).

* * *

After 6592be2
(#68) , if URI contains
the `algorithm` optional parameter, e.g.

```
otpauth://totp/ACME%20Co:[email protected]?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30
```

the application will raise an error:

```
[2023-12-21 09:42:02,769] DEBUG:otp:352: 1 validation error for Uri
schema_ -> TOTPUriSchema -> parameters -> algorithm
  extra fields not permitted (type=value_error.extra)
```
  • Loading branch information
Toreno96 authored Dec 22, 2023
1 parent b763554 commit 961df32
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion onetimepass/otpauth/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import BaseModel
from pydantic import constr
from pydantic import Extra
from pydantic import Field
from pydantic import validator

from .errors import IllegalColon
Expand All @@ -15,7 +16,9 @@
class BaseUriParameters(BaseModel, extra=Extra.forbid):
secret: str
issuer: str | None
hash_algorithm: Literal["SHA1", "SHA256", "SHA512"] = "SHA1"
hash_algorithm: Literal["SHA1", "SHA256", "SHA512"] = Field(
"SHA1", alias="algorithm"
)
digits: int

@validator("issuer")
Expand Down

0 comments on commit 961df32

Please sign in to comment.