Skip to content

Use header-based session token detection instead of bend-v1- prefix #19796

@everpcpc

Description

@everpcpc

Summary

Session tokens are currently identified by a bend-v1- prefix in the Bearer token string (e.g. bend-v1-s-..., bend-v1-r-...). This is a fragile convention that couples token routing to token content.

Proposal

Use a dedicated HTTP header (e.g. X-DATABEND-AUTH-METHOD: session) to distinguish session tokens from other Bearer tokens (JWT, key-pair), consistent with how key-pair auth uses X-DATABEND-AUTH-METHOD: keypair.

This would:

  • Decouple token format from routing logic
  • Make the auth dispatch in session.rs cleaner and more extensible
  • Align all auth methods under a single header-based dispatch model

Current behavior

// src/query/service/src/servers/http/middleware/session.rs
if SessionClaim::is_databend_token(&token) {  // checks bend-v1- prefix
    ...
} else if is_keypair {  // checks X-DATABEND-AUTH-METHOD header
    ...
} else {
    // JWKS JWT
}

Context

Noticed during key-pair auth implementation (#19786) — the header-based approach for key-pair is cleaner than the prefix-based approach for session tokens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions