promoauth
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
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¶
- type Config
- func (c *Config) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
- func (c *Config) Do(ctx context.Context, source Oauth2Source, req *http.Request) (*http.Response, error)
- func (c *Config) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
- func (c *Config) InstrumentHTTPClient(hc *http.Client, source Oauth2Source) *http.Client
- func (c *Config) TokenSource(ctx context.Context, token *oauth2.Token) oauth2.TokenSource
- type Factory
- type InstrumentedOAuth2Config
- type OAuth2Config
- type Oauth2Source
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)InstrumentHTTPClient¶added inv2.8.0
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¶
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
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")