oauth

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTimeout       = 300 * time.Second
	AuthListenAddr    = "localhost"
	AuthListenPort    = 9080
	AuthScheme        = "http://"
	CallBackURL       = "/callback"
	DefaultPerms      = 0o600
	ReadTimeout       = 5 * time.Second
	WriteTimeout      = 5 * time.Second
	IdleTimeout       = 60 * time.Second
	ReadHeaderTimeout = 10 * time.Second
)

Variables

View Source
var (
	ErrOAuthUUID            = errors.New("unable to generate UUID")
	ErrOAuthHTTPServer      = errors.New("unable to start HTTP server")
	ErrOAuthBrowser         = errors.New("unable to open system browser")
	ErrOAuthTimeout         = errors.New("timeout while waiting for authentication to finish")
	ErrOAuthTokenFetch      = errors.New("unable to retrieve token from Google API")
	ErrOAuthTokenSave       = errors.New("unable to save token to file")
	ErrOAuthTokenEncode     = errors.New("unable to encode OAuth token to JSON")
	ErrInvalidCallbackState = errors.New("invalid OAuth callback state")
)

Functions

func GetClient

func GetClient(ctx context.Context, config *oauth2.Config, tokenPath string) (*http.Client, error)

GetClient retrieves an HTTP client with the given context, OAuth2 configuration, and token path.

The function takes in the following parameters: - ctx: the context.Context for the HTTP client. - config: the *oauth2.Config for OAuth2 configuration. - tokenPath: the string representing the path to the token file.

The function returns the following: - *http.Client: the HTTP client. - error: an error if any occurred during the execution of the function.

func LoggingMiddleware added in v0.14.1

func LoggingMiddleware() gin.HandlerFunc

LoggingMiddleware is a middleware function that logs HTTP server requests.

It takes a gin.Context as a parameter and logs the method, URI, status, client IP, and duration of the request. It does not return any values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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