Allow setting additional data for OpenID model
sammaphey opened this issue · 4 comments
This class should allow additional fields instead of just the base fields. There are more useful pieces of information I need as a response from verify_and_process
such as: User citizenship, phone number, etc.
Wouldn't it be better if your provider returned a subclass of OpenID
? In #31 there is no IDE autocomplete for the fields you add as extra. If you subclass OpenID
, add your custom fields, and then return your custom OpenID
from verify_and_process
, you get what you need and still keep all fields transparent.
Yeah, this is what I ended up doing, I guess it seems odd that I must subclass OpenID
when all I really want is the data that is returned from my SSO server. It seems like something that I shouldn't have to enforce a BaseModel
for since as far as I can tell here the only advantage I get is some dot notation and typeahead for static analysis. But your answer does make sense so I am happy to have the issue closed.
Hi again, I've been thinking about this for quite some time now and I understand getting a Pydantic model as a response may not always be what you want. And so I will introduce a way to actually get the bare json
response from the server instead. Thank you for this thought-provoking issue.
@sammaphey you can just subclass your SSO and override openid_from_response
to return something potentially different. If it's a subclass of OpenID
even the type info would be correct :)