mirror of
https://github.com/fleetdm/fleet
synced 2026-05-04 05:48:26 +00:00
Implements #32247. This is the complete feature branch, consolidating: - https://github.com/fleetdm/fleet/pull/35018 - https://github.com/fleetdm/fleet/pull/34758 - https://github.com/fleetdm/fleet/pull/35009 - https://github.com/fleetdm/fleet/pull/35181 - https://github.com/fleetdm/fleet/pull/35342 --------- Co-authored-by: Jonathan Katz <44128041+jkatz01@users.noreply.github.com> Co-authored-by: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: jkatz01 <yehonatankatz@gmail.com>
21 lines
748 B
Go
21 lines
748 B
Go
// Package certserial provides a context key for storing client certificate serial numbers
|
|
// extracted from HTTP headers during mTLS authentication for device endpoints.
|
|
package certserial
|
|
|
|
import "context"
|
|
|
|
type key int
|
|
|
|
const certSerialKey key = 0
|
|
|
|
// NewContext returns a new context.Context with the provided certificate serial number.
|
|
func NewContext(ctx context.Context, serial uint64) context.Context {
|
|
return context.WithValue(ctx, certSerialKey, serial)
|
|
}
|
|
|
|
// FromContext returns the certificate serial number from the context, if present.
|
|
// The second return value indicates whether a serial number was found.
|
|
func FromContext(ctx context.Context) (uint64, bool) {
|
|
serial, ok := ctx.Value(certSerialKey).(uint64)
|
|
return serial, ok
|
|
}
|