Movatterモバイル変換


[0]ホーム

URL:


promoauth

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:9Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Overview

Package promoauth is for instrumenting oauth2 flows with prometheus metrics.Specifically, it is intended to count the number of external requests madeby the underlying oauth2 exchanges.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeConfig

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

func (*Config)AuthCodeURL

func (c *Config) AuthCodeURL(statestring, opts ...oauth2.AuthCodeOption)string

func (*Config)Do

func (c *Config) Do(ctxcontext.Context, sourceOauth2Source, req *http.Request) (*http.Response,error)

func (*Config)Exchange

func (c *Config) Exchange(ctxcontext.Context, codestring, opts ...oauth2.AuthCodeOption) (*oauth2.Token,error)

func (*Config)InstrumentHTTPClientadded inv2.8.0

func (c *Config) InstrumentHTTPClient(hc *http.Client, sourceOauth2Source) *http.Client

InstrumentHTTPClient will always return a new http client. The new client willmatch the one passed in, but will have an instrumented round tripper.

func (*Config)TokenSource

func (c *Config) TokenSource(ctxcontext.Context, token *oauth2.Token)oauth2.TokenSource

typeFactory

type Factory struct {// optional replace now funcNow func()time.Time// contains filtered or unexported fields}

Factory allows us to have 1 set of metrics for all oauth2 providers.Primarily to avoid any prometheus errors registering duplicate metrics.

funcNewFactory

func NewFactory(registryprometheus.Registerer) *Factory

func (*Factory)New

func (f *Factory) New(namestring, underOAuth2Config) *Config

func (*Factory)NewGithub

func (f *Factory) NewGithub(namestring, underOAuth2Config) *Config

NewGithub returns a new instrumented oauth2 config for github. It tracksrate limits as well as just the external request counts.

typeInstrumentedOAuth2Config

type InstrumentedOAuth2Config interface {OAuth2Config// Do is provided as a convenience method to make a request with the oauth2 client.// It mirrors `http.Client.Do`.Do(ctxcontext.Context, sourceOauth2Source, req *http.Request) (*http.Response,error)}

InstrumentedOAuth2Config extends OAuth2Config with a `Do` method that allowsexternal oauth related calls to be instrumented. This is to support"ValidateToken" which is not an oauth2 specified method.These calls still count against the api rate limit, and should be instrumented.

typeOAuth2Config

type OAuth2Config interface {AuthCodeURL(statestring, opts ...oauth2.AuthCodeOption)stringExchange(ctxcontext.Context, codestring, opts ...oauth2.AuthCodeOption) (*oauth2.Token,error)TokenSource(context.Context, *oauth2.Token)oauth2.TokenSource}

OAuth2Config exposes a subset of *oauth2.Config functions for easier testing.*oauth2.Config should be used instead of implementing this in production.

typeOauth2Source

type Oauth2Sourcestring
const (SourceValidateTokenOauth2Source = "ValidateToken"SourceExchangeOauth2Source = "Exchange"SourceTokenSourceOauth2Source = "TokenSource"SourceAppInstallationsOauth2Source = "AppInstallations"SourceAuthorizeDeviceOauth2Source = "AuthorizeDevice"SourceGitAPIAuthUserOauth2Source = "GitAPIAuthUser"SourceGitAPIListEmailsOauth2Source = "GitAPIListEmails"SourceGitAPIOrgMembershipsOauth2Source = "GitAPIOrgMemberships"SourceGitAPITeamMembershipsOauth2Source = "GitAPITeamMemberships")

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp