oauth2client

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 6 Imported by: 2

README

KrakenD oauth2 client credentials

A http client for the KrakenD framework supporting the oauth2 client credentials workflow.

How to use it?

This package exposes single factory capable to create a instances of the proxy.HTTPClientFactory interface embedding a http client supporting the oauth2 client credentials workflow

import 	(
	"context"
	"net/http"
	"github.com/luraproject/lura/config"
	"github.com/luraproject/lura/proxy"
	"github.com/devopsfaith/krakend-oauth2-clientcredentials"
)

requestExecutorFactory := func(cfg *config.Backend) proxy.HTTPRequestExecutor {
	clientFactory := oauth2client.NewHTTPClient(cfg)
	return func(ctx context.Context, req *http.Request) (*http.Response, error) {
		return clientFactory(ctx).Do(req.WithContext(ctx))
	}
}

You can create your own proxy.HTTPRequestExecutor and inject it into your BackendFactory

Documentation

Index

Constants

View Source
const Namespace = "github.com/devopsfaith/krakend-oauth2-clientcredentials"

Namespace is the key to use to store and access the custom config data

Variables

View Source
var ZeroCfg = Config{}

ZeroCfg is the zero value for the Config struct

Functions

func NewHTTPClient

func NewHTTPClient(cfg *config.Backend) client.HTTPClientFactory

NewHTTPClient creates a HTTPClientFactory with an http client configured for dealing with all the logic related to the oauth2 client credentials grant

Types

type Config

type Config struct {
	IsDisabled     bool
	ClientID       string
	ClientSecret   string
	TokenURL       string
	Scopes         string
	EndpointParams map[string][]string
}

Config is the custom config struct containing the params for the golang.org/x/oauth2/clientcredentials package

Jump to

Keyboard shortcuts

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