Releases: lsst-sqre/safir
Releases · lsst-sqre/safir
3.0.3
3.0.2
3.0.1
safir.database
retains the port in the database URL, if provided.
3.0.0
XForwardedMiddleware
no longer setsforwaded_proto
in the request state and instead directly updates the request scope so that subsequent handlers and middleware believe the request scheme is that given by anX-Forwarded-Proto
header. This fixes the scheme returned by other request methods and attributes such asurl_for
in cases where the service is behind an ingress that terminates TLS.- Add new FastAPI dependencies
auth_dependency
andauth_logger_dependency
from thesafir.dependencies.gafaelfawr
module.auth_dependency
returns the username of the user authenticated via Gafaelfawr (pulled from theX-Auth-Request-User
header.auth_logger_dependency
returns the same logger aslogger_dependency
but with theuser
parameter bound to the username fromauth_dependency
. - Add utility functions to initialize a database and create a sync or async session. The session creation functions optionally support a health check to ensure the database schema has been initialized.
- Add new FastAPI dependency
db_session_dependency
that creates a task-local async SQLAlchemy session. - Add utility functions
datetime_from_db
anddatetime_to_db
to convert between timezone-naive UTC datetimes stored in a database and timezone-aware UTC datetimes used elsewhere in a program. - Add a
run_with_async
decorator that runs the decorated async function synchronously. This is primarily useful for decorating Click command functions (for a command-line interface) that need to make async calls.
2.4.0
2.3.0
2.2.0
2.1.1
2.1.0
- Add
safir.models.ErrorModel
, which is a model of the error message format preferred by FastAPI. Using the model is not necessary but it's helpful to reference it in API documentation to generate more complete information about the error messages. - Mark all FastAPI dependencies as async so that FastAPI doesn't run them in an external thread pool.