authid

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

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

View Source
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

func Parse(raw string) (id.ID, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL