tokusumi / fastapi-cloudauth

Simple integration between FastAPI and cloud authentication services (AWS Cognito, Auth0, Firebase Authentication).
MIT License
323 stars 35 forks source link

Support multiple scope #43

Closed tokusumi closed 3 years ago

tokusumi commented 3 years ago

Support a part of #35, multiple scopes with all and any combinator. As:

from fastapi_cloudauth import Operator

@app.get("/access-all/")
def secure_access_and(scope=Depends(auth.scope(["role_admin", "super_admin"]))):
    return f"Hello {scope}"

@app.get("/access-any/")
def secure_access_or(scope=Depends(auth.scope(["role_admin", "super_admin"], op=Operator._any))):
    return f"Hello {scope}"
codecov[bot] commented 3 years ago

Codecov Report

Merging #43 (18d4ffb) into master (9e086f2) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #43   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines         1023      1095   +72     
=========================================
+ Hits          1023      1095   +72     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
fastapi_cloudauth/base.py 100.00% <100.00%> (ø)
fastapi_cloudauth/verification.py 100.00% <100.00%> (ø)
tests/test_auth0.py 100.00% <100.00%> (ø)
tests/test_base.py 100.00% <100.00%> (ø)
tests/test_cloudauth.py 100.00% <100.00%> (ø)
tests/test_cognito.py 100.00% <100.00%> (ø)
tests/test_verification.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9e086f2...18d4ffb. Read the comment docs.

masus04 commented 2 years ago

This is exactly what I need, could you add some documentation to the readme for how it is used?

Specifically I don't understand what the auth object is and where I can get it from.

Thank you!