Skip to content

The Bearer scheme is matched case-sensitively #21

Open

Description

@sujal-maheshwari2004

Summary

Both providers require the authorization value to start with exactly Bearer followed by the token. HTTP authentication scheme names are case-insensitive, and some clients send bearer.

Impact

A client or proxy that lower-cases the scheme, or sends two spaces, is rejected with invalid or missing token even though the token is correct. The cause is not obvious from the message.

Steps to reproduce

p := authn.NewStatic(map[string]authn.Token{"s3cret": {Write: true}})
_, err1 := p.Authenticate(ctx, "Bearer s3cret")
_, err2 := p.Authenticate(ctx, "bearer s3cret")
fmt.Println(err1, err2)

Actual: <nil> credential not recognized.

Expected behavior

The scheme is compared case-insensitively and surrounding whitespace is ignored. The token itself is still compared in constant time.

Where to look

Suggested approach

Parse the header once into scheme and credential in a shared helper, check the scheme with strings.EqualFold, and compare only the credential bytes.

Getting started

  • You need Go 1.25 or newer. From the repo root, go test ./... runs everything; no services are needed.
  • The code is in authn/ (library) and cmd/priompt-auth/ (the token service). Tests sit next to each file and use httptest. Start in authn/authn.go.

Acceptance criteria

  • bearer, BEARER and Bearer all authenticate with a valid token.
  • A different scheme (Basic …) is still rejected.
  • The comparison of the token remains constant-time.

Activity

  1. ghost added
    bugSomething isn't working
    on Nov 15, 2026
  2. ghost
    self-assigned this
    on Nov 18, 2026
  3. 3 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions