adriangb / xpresso

A composable Python ASGI web framework
https://xpresso-api.dev/
MIT License
176 stars 4 forks source link

POC for security classes using Protocol #79

Open adriangb opened 2 years ago

adriangb commented 2 years ago

This uses Protocols to create "template classes": classes that give you errors if you don't implement all of the required class variables.

This at least allows some typechecking of missing parameters and wrongly typed parameters

Screenshot 2022-02-27 223825 Screenshot 2022-02-27 223609
codecov-commenter commented 2 years ago

Codecov Report

Merging #79 (0ab0a77) into main (6e46ab0) will decrease coverage by 0.04%. The diff coverage is 96.24%.

@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
- Coverage   98.11%   98.07%   -0.05%     
==========================================
  Files         144      151       +7     
  Lines        4565     4778     +213     
  Branches      738      770      +32     
==========================================
+ Hits         4479     4686     +207     
- Misses         44       47       +3     
- Partials       42       45       +3     
Impacted Files Coverage Δ
xpresso/binders/_security/apikey.py 88.46% <88.46%> (ø)
xpresso/binders/_security/oauth2.py 89.65% <89.65%> (ø)
xpresso/binders/api.py 97.50% <94.11%> (-2.50%) :arrow_down:
tests/test_security/test_multiple_models.py 98.30% <98.30%> (ø)
tests/test_security/test_security_key_header.py 100.00% <100.00%> (ø)
.../test_security_oauth2_authorization_code_bearer.py 100.00% <100.00%> (ø)
xpresso/binders/_security/utils.py 100.00% <100.00%> (ø)
xpresso/security.py 100.00% <100.00%> (ø)
xpresso/exception_handlers.py 100.00% <0.00%> (+20.00%) :arrow_up: