lablink_allocator_service.auth¶
lablink_allocator_service.auth
¶
Authentication for the allocator service.
Two independent gates:
auth— HTTP Basic, admin operator credentials, guards/admin/*and the operator JSON APIs.require_client_secret— Bearer token, per-client secret minted at registration, guards the client-VM → allocator telemetry endpoints.
This module exists separately from main so blueprints can apply
@auth.login_required as a normal decorator at import time. main
creates the Flask app and imports the blueprints, so an auth defined in
main does not exist yet when a blueprint module body executes.
users and database stay on main and are read through a lazy import
at request time — the test suite patches main.users and main.database,
and a module-level binding here would freeze pre-patch values.
Attributes¶
auth = HTTPBasicAuth()
module-attribute
¶
Functions:¶
require_client_secret(f)
¶
Require a valid per-client secret Bearer token. The client row is
resolved from the request's hostname field (vm_id for heartbeat,
else hostname; falls back to a hostname route kwarg).
Source code in packages/allocator/src/lablink_allocator_service/auth.py
verify_password(username, password)
¶
Verify the username and password against the stored users. Args: username (str): The username to verify. password (str): The password to verify. Returns: str: The username if the credentials are valid, None otherwise.