userinfo

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package userinfo calls GitLab Rails' `/api/v4/iam/userinfo` endpoint, authenticated with the access token minted for the same token exchange as a bearer credential. Unlike `/oauth/userinfo`, that endpoint only accepts an IAM-issued OAuth JWT, so it exists to serve exactly this caller.

Index

Constants

View Source
const RequestTimeout = 3 * time.Second

RequestTimeout bounds each attempt so a slow or hanging endpoint can't stall a token exchange indefinitely. Exported so callers constructing the *http.Client passed to NewClient can size its Timeout the same way. Kept short: this is an internal, same-infrastructure call, and the client is waiting synchronously on it.

Variables

View Source
var ErrFetchFailed = errors.New("user info unavailable")

ErrFetchFailed is the only error FetchUserInfo ever returns. fosite's stock OpenIDConnectExplicitHandler echoes a failing storage call's error string verbatim to the OAuth client as error_debug (WriteOAuthError in auth/oauth/server/errors.go copies it through unconditionally), so the real cause — which can include this endpoint's host or a raw dial error — is logged here instead of returned.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, httpClient *http.Client, logger *logrus.Entry) *Client

NewClient wraps httpClient in retryablehttp's default retry policy: a network error or a 5xx/429 response retries once with a short backoff; a 4xx or a decode failure never retries. The underlying client's Timeout is forced to RequestTimeout — httpClient's other fields (Transport, Jar, CheckRedirect) are kept, but its Timeout is not trusted, so this package bounds every attempt itself rather than depending on the caller having set it correctly. Without that, a zero-value Timeout would let an attempt hang indefinitely, and the token exchange is waiting on it synchronously.

func (*Client) FetchUserInfo

func (c *Client) FetchUserInfo(ctx context.Context, accessToken string) (map[string]any, error)

Jump to

Keyboard shortcuts

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