spruceid / siwe-py

A Python implementation of Sign-In with Ethereum
https://login.xyz
Apache License 2.0
67 stars 30 forks source link

update to pydantic v2 #51

Closed ameyarao98 closed 6 months ago

ameyarao98 commented 1 year ago

Closes #50 and #46

Note: Tests currently fail because the AnyUrl type always appends a / at the end:

>>> from pydantic import AnyUrl, BaseModel
>>> class x(BaseModel):
...     a:AnyUrl
... 
>>> x(a="https://tally.xyz")
x(a=Url('https://tally.xyz/'))

Either find a way to modify it not to do that or go for a simple string instead https://github.com/pydantic/pydantic/issues/7186

sbihel commented 1 year ago

Tests currently fail because the AnyUrl type always appends a / at the end

Related to that, it's the reason why there was a custom date type, to enable transitivity. Mainly because the verification method re-serialises the message before verifying the method. Which is arguably a wasteful process.

I see a few alternatives:

The last two are kind of the same, and I think it's probably the best way to go about it, JWT-style verification.

Do you have an opinion?

xcaptain commented 1 year ago

If the AnyUrl thing got fixed, please also upgrade eth-account, the current 0.8.0 is old

ameyarao98 commented 7 months ago

Do you have an opinion?

Just seeing this but I agree that split the SiweMessage type into SiweMessageBuilder and SignedSiweMessage. is the right way to go. I do think that that might be beyond the scope of the PR however,. For now I think making AnyUrl a string instead might be better, since I did have a similar issue with another project and I concluded that the benefits of Pydantic validating URL structure are minimal

sbihel commented 6 months ago

Closed by #59