Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
FastAPI create auth for all endpoints

I followed this documentation to setup up a single user: https://fastapi.tiangolo.com/advanced/security/http-basic-auth/

But I only get prompted for user/pass for that one end point, "/users/me".

How do I ensure that all endpoints are behind auth?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can configure FastAPI with a set of dependencies that needs to be resolved for any endpoint by giving the paramter directly when creating the FastAPI application (i.e. global dependencies):

security = HTTPBasic()

app = FastAPI(dependencies=[Depends(security)])

If you want some endpoints to be authenticated and some to be unauthenticated, you can create separate instances of APIRouter, then assign required dependencies to the one that require authentication:

unauthenticated_router = APIRouter()
authenticated_router = APIRouter(dependencies=[Depends(security)])

.. and then either include other routers under each (using .include_router) or register endpoints as you'd do with the app object - but instead use your two routers.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda