Skip to main content

auth_when_required

Function auth_when_required 

Source
pub async fn auth_when_required(
    __arg0: State<(AppStateData, Accepts)>,
    request: Request,
    next: Next,
) -> Response
Expand description

Middleware that rejects requests without a login of one of the accepted methods when settings.registry.auth_required is true.

Endpoints for cargo answer with a WWW-Authenticate header. Cargo and other registry clients retry with credentials after a 401, so /config.json is not public even if auth_required is true. See:

If both methods are accepted, every failed login is a 401.