Skip to content

Web API

FastAPI Application

dbcreds.web.main.app = FastAPI(title='dbcreds Web', description='Database Credentials Management', version=__version__, lifespan=lifespan) module-attribute

Routes

dbcreds.web.main

FastAPI web application for dbcreds.

Provides a web interface for managing database credentials with team collaboration features.

Functions

index(request: Request) async

Home page.

create_environment(request: Request) async

Create a new environment.

list_environments(request: Request) async

List all environments (HTMX endpoint).

edit_environment_form(request: Request, env_name: str) async

Get edit form for an environment.

update_environment(request: Request, env_name: str) async

Update an environment.

test_environment(request: Request, env_name: str) async

Test environment connection.

get_environment_expiry(env_name: str) async

Get password expiry information for an environment.

Authentication

dbcreds.web.auth

Authentication for the web interface.

Functions

get_current_user(credentials: HTTPBasicCredentials = Depends(security)) async

Get the current authenticated user.

authenticate_user(username: str, password: str) -> bool

Authenticate a user.

Error Handling

dbcreds.web.errors.WebErrorHandler()

Rich error handler for web interface.

Initialize with a console for stderr output.

Functions

get_error_response(request: Request, error: Exception, status_code: int = status.HTTP_500_INTERNAL_SERVER_ERROR) -> HTMLResponse

Get HTML error response for the web interface.

log_error(error: Exception, request: Optional[Request] = None) -> None

Log error with rich formatting to console.