Skip to content

Conversation

Copy link

Copilot AI commented Jan 22, 2026

The /sign/key endpoint with IrmaAuthType::Key was always registered, causing middleware initialization to fail when db_pool is None (lines 305-309 in irma.rs). Since database configuration is optional, this prevented server startup in valid configurations.

Changes:

  • Refactored IRMA scope registration to use mutable variable pattern
  • Conditionally register API-key /sign/key service only when db_pool.is_some()
  • JWT authentication fallback remains unconditionally available

Before:

.service(
    resource("/sign/key")
        .wrap({
            let auth = IrmaAuth::new(irma.clone(), IrmaAuthType::Key);
            if let Some(ref pool) = db_pool {
                auth.with_db_pool(Data::clone(pool))
            } else {
                auth  // <- Still fails at middleware init
            }
        })
)

After:

let mut irma_scope = scope("/{_:(irma|request)}")
    .service(/* other services */);

if let Some(ref pool) = db_pool {
    irma_scope = irma_scope.service(
        resource("/sign/key")
            .wrap(IrmaAuth::new(irma, IrmaAuthType::Key)
                .with_db_pool(Data::clone(pool)))
    );
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: FayKn <61050421+FayKn@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on bug fix in CLI tool Conditionally register Key auth endpoint based on DB pool availability Jan 22, 2026
Copilot AI requested a review from FayKn January 22, 2026 12:43
@FayKn FayKn marked this pull request as ready for review January 22, 2026 12:55
@FayKn FayKn merged commit 095cbec into api-key Jan 22, 2026
@FayKn FayKn deleted the copilot/sub-pr-43 branch January 22, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants