duo-labs / py_webauthn

Pythonic WebAuthn 🐍
https://duo-labs.github.io/py_webauthn
BSD 3-Clause "New" or "Revised" License
838 stars 165 forks source link

Expose data structures publically #101

Closed jwag956 closed 2 years ago

jwag956 commented 2 years ago

First - thanks so much for updating this library. I have successfully integrated it into Flask-Security...

The main APIs: e.g. generate_registration_options all are nicely typed using data structures defined via pydantic in helpers/structs.py. Currently those are not listed in init.py and thus are not 'declared' public.

This is requesting that the structs and exceptions be listed in init.py.

MasterKale commented 2 years ago

Ah, interesting feedback. I'd have marked modules as "private" with an underscore prefix (e.g. webauthn._helpers) if I didn't intend for people to import from it, but in this case everything is there for people to pull in. This is my first time releasing a Python library of this relative complexity - is it bad practice to lean on Python's general openness to importing from any internal module, and instead specifically import into the root-level init.py anything that should be considered "public"?

And is your request that webauthn.helpers.structs and webauthn.helpers.exceptions become webauthn.structs and webauthn.exceptions? Or that all structs and exceptions are flattened and exposed directly on webauthn?

jwag956 commented 2 years ago

Well - I have seen things done 2 ways - most of the Flask packages import all the public API into init.py - this has an advantage of 'hiding' the underlying module layout.

But I just looked at Werkzeug and Passlib - and they simply document that the caller should import a sub-module e.g. for passlib the API says: from passlib.hash import pbkdf2_sha256

So that is pretty much what you folks are doing .... I think I will close this - it might be useful to add to the docs that exceptions are also available.

Thanks for your quick response.