api

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OAuthAppsFromConfig

func OAuthAppsFromConfig(appsConfig []oauthapps.OAuthAppConfig, baseURL string) (map[string]OAuthApp, error)

func RegisterAPI

func RegisterAPI(context *Context, oauthApps map[string]OAuthApp, cache StateCache, metrics *metrics.Collector, cfg Config) (*mux.Router, error)

RegisterAPI registers the API endpoints on the given router.

Types

type AppCtxHandlerFunc added in v0.1.1

type AppCtxHandlerFunc func(c *OAuthAppContext, w http.ResponseWriter, r *http.Request)

type AuthFormData added in v0.1.1

type AuthFormData struct {
	RedirectURL    string
	ConfirmAuthURL string
	ProviderName   string
	ProviderURL    string
	CancelAuthURL  string
	CsrfField      template.HTML
}

type Config added in v0.1.1

type Config struct {
	BaseURL                  string
	ConfirmationTemplatePath string
	CancelPagePath           string
	StylesFilePath           string
}

type Context

type Context struct {
	RequestID string
	Logger    logrus.FieldLogger
}

func (*Context) Clone

func (c *Context) Clone() *Context

func (*Context) Setup added in v0.1.1

func (c *Context) Setup(r *http.Request)

type CtxHandlerFunc

type CtxHandlerFunc func(c *Context, w http.ResponseWriter, r *http.Request)

type Handler

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

func NewHandler

func NewHandler(cache StateCache, baseURL *url.URL, confirmFormPath, cancelPagePath string, metricsCollector *metrics.Collector) (*Handler, error)

type OAuthApp

type OAuthApp struct {
	oauthapps.OAuthAppConfig
	OAuthURLs
}

type OAuthAppContext added in v0.1.1

type OAuthAppContext struct {
	*Context
	OAuthApplication OAuthApp
}

OAuthAppContext is Context that includes OAuth Application. The application is derived from path variables on routs such as `v1/github/plugin-github/...`.

type OAuthURLs

type OAuthURLs interface {
	Endpoint() oauth2.Endpoint
	RedirectURL() string
}

func NewOAuthURLs

func NewOAuthURLs(provider providers.OAuthProvider, appIdentifier, baseURL string, extraData map[string]interface{}) (OAuthURLs, error)

type StateCache

type StateCache interface {
	GetRedirectURI(state string) (cache.AuthorizationState, error)
	SetRedirectURI(state string, authzState cache.AuthorizationState) error
	DeleteState(state string) error
}

type TokenResponse added in v0.1.3

type TokenResponse struct {
	oauth2.Token
	ExpiresIn float64 `json:"expires_in"`
}

Jump to

Keyboard shortcuts

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