Giter Site home page Giter Site logo

Comments (7)

tokusumi avatar tokusumi commented on May 27, 2024 1

@spawn-guy sorry for late response.
would you mind post your solution for other user?

from fastapi-cloudauth.

spawn-guy avatar spawn-guy commented on May 27, 2024

we've found a different and an easier way as documentation suggests

from fastapi-cloudauth.

spawn-guy avatar spawn-guy commented on May 27, 2024

even though we migrated to fastapi-auth0 (although i wanted to use this one as this one has support for a few jwt issuers) - we've decided to not to instantiate it as a dependency injection, but as a "global" namespaced instance

file: app/core/auth.py

from fastapi_cloudauth import Auth0
auth0 = Auth0(domain=domain=AUTH0_DOMAIN)

then in another route we can use it as

from app.core.auth import auth0

@router.get("/something",
            response_model=Any,
            dependencies=[
                Depends(auth0.scope("read:something"))
            ]
            )
async def get_something(
        request: Request
):
    return []

the Depends/Security will cache the instance between the calls

from fastapi-cloudauth.

tivaliy avatar tivaliy commented on May 27, 2024

This issue is closed, but I still have a question and faced with exact problem, so how to use Cognito/Auth0.. etc instance as a part of app context. Any thoughts?

from fastapi-cloudauth.

spawn-guy avatar spawn-guy commented on May 27, 2024

it's been some time, so i don't recall many things, but

@tivaliy try the snippet above. but replace Auth0 with Cognito.

create an instance in 1 file (app/core/auth.py) - import that instance in the router(s)

from fastapi-cloudauth.

tivaliy avatar tivaliy commented on May 27, 2024

@spawn-guy,

Thank you for the response, but the idea in my case is to use exact approach you mentioned in the very beginning of this thread.

from fastapi-cloudauth.

spawn-guy avatar spawn-guy commented on May 27, 2024

@spawn-guy,

Thank you for the response, but the idea in my case is to use exact approach you mentioned in the very beginning of this thread.

Well, good luck. Let us know when/if you will figure it out

from fastapi-cloudauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.