auth

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenNotFound    = errors.New("OAuth token not found")
	ErrClientIDNotFound = errors.New("OAuth client ID not found")
)

Functions

func ClientID

func ClientID(clientID, issuer string) (string, error)

ClientID returns the client ID for the given issuer. If clientID is not empty, it is returned. If issuer is empty, it defaults to defaultIssuer. If issuer is unknown, ErrClientIDNotFound is returned.

func Config

func Config(baseURL, clientID string) (*oauth2.Config, error)

Config creates an OAuth2 config for the GitLab instance at baseURL. If baseURL is empty, it defaults to gitlab.com.

func FileTokenSource

func FileTokenSource(ctx context.Context, issuer, filename string, config *oauth2.Config) oauth2.TokenSource

FileTokenSource returns an oauth2.TokenSource that is backed by a file on the file system. The token is refreshed automatically. New tokens are automatically written to the file.

func StoreToken

func StoreToken(filename, issuer string, token *oauth2.Token, options ...storeTokenOption) error

StoreToken writes the provided token to the specified file.

func TokenPath

func TokenPath() string

TokenPath returns the path of the token file based on the operating system:

- Mac OS: `~/Library/Application Support/gitlab-mcp/token.json` - Linux: `~/.config/gitlab-mcp/token.json` - Windows: `%APPDATA%\gitlab-mcp\token.json` - Other: `~/.gitlab-mcp/token.json`

func Wrap added in v1.23.0

func Wrap(hndl http.Handler) http.Handler

Wrap wraps an HTTP handler to check for the presence of a "Private-Token" header. If the header is present, the request is passed to the wrapped handler. Otherwise, a 401 Unauthorized status is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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