Colin-b / httpx_auth

Authentication classes to be used with httpx
MIT License
114 stars 26 forks source link

Custom auth code templates #74

Closed blag closed 7 months ago

blag commented 7 months ago

Instead of hard-coding the HTML templates for the authorization code flow, expose them as options to OAuth2AuthorizationCode and all subclasses.

This allows users of this library to ensure that the templates match their site branding.

The new parameters are optional and default to values that are the exact same HTML as before.

I don't fully document what the default templates are, since I'm not really sure where the best place to do so would be.

Also added tests to ensure they work properly.

Colin-b commented 7 months ago

This whole set of parameters for display only is due for a rework anyway. This is a great new feature, implementation wise I'd see a single parameter (or maybe something decoupled from the auth class entirely, need to think about it a bit)

sonarcloud[bot] commented 7 months ago

Quality Gate Failed Quality Gate failed

Failed conditions
27.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Colin-b commented 7 months ago

Thanks for the work on this. As said, I think I will rework it a bit before pushing it as part of a new release.

blag commented 7 months ago

Sounds good, I appreciate you picking it up and running with it. And thank you for authoring this project to begin with. httpx and this project have greatly simplified what I'm doing!

Feel free to ping me for any reviews or whatever regarding this feature. I'm already using my fork in a dev environment, so I can easily try out whatever you cook up and offer feedback/user testing.

Colin-b commented 6 months ago

Thanks for the proposal @blag , this new feature will be part of next release and you can already test it in the develop branch (check the README / CHANGELOG files on develop for more details on the changes related to this)

tl;dr: The templates are now provided via httpx_auth.OAuth2.display.success_html / failure_html. The defaults also changed to be more modern, you can check them out :)

Colin-b commented 6 months ago

Release 0.21.0 is now available on pypi

blag commented 6 months ago

Looks great, thank you for being so responsive!