Documentation
¶
Overview ¶
Package authid turns the user id carried by an authenticated request into the neutral id.ID every repository takes, so each controller doesn't repeat the same parse-and-map-the-error block.
It takes the raw user-id string rather than a gin context or the auth SDK's UserAuthInfo on purpose: that type has changed across SDK releases (its UserID was once a primitive.ObjectID, now a string). Taking the string keeps shared independent of that type and avoids a release-order cycle between shared and the SDK.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidUserID = errors.New("invalid user id")
ErrInvalidUserID is returned (wrapped) by Parse for an empty or malformed user id. Callers should map it to the HTTP status their auth conventions use for a bad token subject (400/401) with errors.Is.
Functions ¶
func Parse ¶
Parse converts the raw authenticated-user id (an ObjectID hex string from a pre-cutover token, or a uuid) into an id.ID. An empty or unparseable value is an error wrapping both ErrInvalidUserID and id.ErrInvalid, never a zero id: a zero id would reach repositories and the storage-quota check as an identity that matches nothing.
Types ¶
This section is empty.