Skip to content

feat(sasl): add OAUTHBEARER mechanism (RFC 7628)#1418

Open
pilat wants to merge 1 commit intosegmentio:mainfrom
pilat:feat/oauthbearer-sasl
Open

feat(sasl): add OAUTHBEARER mechanism (RFC 7628)#1418
pilat wants to merge 1 commit intosegmentio:mainfrom
pilat:feat/oauthbearer-sasl

Conversation

@pilat
Copy link

@pilat pilat commented Jan 7, 2026

Implements OAUTHBEARER SASL authentication mechanism per RFC 7628.

Closes #238

Changes

  • Add sasl/oauthbearer package with Mechanism type
  • TokenFunc callback enables automatic token refresh on reconnection
  • Structured Error type with errors.Is/errors.As support
  • RFC 7628 compliant: returns 0x01 dummy response on auth failure
  • Unit tests and integration tests against local Kafka

Design

Uses TokenFunc func(ctx context.Context) (string, error) callback instead of static token field. This allows token refresh when connections are re-established, which is essential for short-lived OAuth tokens.

Example usage:

mechanism := &oauthbearer.Mechanism{
    TokenFunc: func(ctx context.Context) (string, error) {
        return getTokenFromProvider(ctx)
    },
}

Testing

  • Unit tests cover all code paths
  • Integration tests run against Kafka with unsecured OAUTHBEARER mode
  • Docker-compose updated to expose OAUTHBEARER listener on port 9094

@pilat pilat force-pushed the feat/oauthbearer-sasl branch from ef6d33b to 6d7d4c9 Compare January 7, 2026 13:00
@pilat pilat marked this pull request as draft January 7, 2026 14:36
@pilat pilat marked this pull request as ready for review January 7, 2026 14:49
@pilat pilat force-pushed the feat/oauthbearer-sasl branch 2 times, most recently from 4dfa466 to 36d0962 Compare January 7, 2026 15:48
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.

SASL: add support for OAUTHBEARER mechanism

1 participant