Skip to content

feat: Context.BasicAuth() convenience method #56

@FumingPower3925

Description

@FumingPower3925

Summary

Add Context.BasicAuth() (username, password string, ok bool) that parses the Authorization: Basic <base64> header.

Motivation

While users can already do c.Header("authorization") + manual base64 decode, this is a common enough pattern that a convenience method improves DX. Gin, Echo, and the standard library all provide this.

Scope

  • Parse authorization header for Basic scheme.
  • Base64-decode and split on :.
  • Return (username, password, true) or ("", "", false) if not present/invalid.
  • Implementation: ~10 lines, mirrors net/http.Request.BasicAuth().

Non-breaking

Additive method on Context. No existing API changes required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiPublic-facing API surfaceenhancementNew feature or requestsize/S~1 day of work

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions