client

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package client implements a low-level OAuth2 client to perform the various request/response flows against a OAuth2 authentication server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildIntrospectionRequest

func BuildIntrospectionRequest(uri string, r introspection.Request) (*http.Request, error)

BuildIntrospectionRequest will build the provided request.

func BuildRevocationRequest

func BuildRevocationRequest(uri string, r revocation.Request) (*http.Request, error)

BuildRevocationRequest will build the provided request.

func BuildTokenRequest

func BuildTokenRequest(uri string, r oauth2.TokenRequest) (*http.Request, error)

BuildTokenRequest will build a request from the provided data.

func IntrospectionRequestValues

func IntrospectionRequestValues(r introspection.Request) url.Values

IntrospectionRequestValues will return the form values for the provided request.

func ParseIntrospectionResponse

func ParseIntrospectionResponse(res *http.Response) (*introspection.Response, error)

ParseIntrospectionResponse will parse the provided response.

func ParseRequestError

func ParseRequestError(res *http.Response) error

ParseRequestError will try to parse an oauth2.Error from the provided response. It will fallback to an Error containing the servers response.

func ParseTokenResponse

func ParseTokenResponse(res *http.Response) (*oauth2.TokenResponse, error)

ParseTokenResponse will parse the provided response.

func RevocationRequestValues

func RevocationRequestValues(r revocation.Request) url.Values

RevocationRequestValues will return the form values for the provided request.

func TokenRequestValues

func TokenRequestValues(r oauth2.TokenRequest) url.Values

TokenRequestValues will return the form values for the provided request.

Types

type Client

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

Client is a low-level OAuth2 client.

func New

func New(config Config) *Client

New will create and return a new client.

func (*Client) Authenticate

func (c *Client) Authenticate(trq oauth2.TokenRequest) (*oauth2.TokenResponse, error)

Authenticate will send the provided token request and return the servers token response or an error if failed.

func (*Client) Introspect

func (c *Client) Introspect(irq introspection.Request) (*introspection.Response, error)

Introspect will send the provided introspection request and return the servers response of an error if failed.

func (*Client) Revoke

func (c *Client) Revoke(rrq revocation.Request) error

Revoke will send the provided revocation request and return and error if it failed.

type Config

type Config struct {
	BaseURI               string
	TokenEndpoint         string
	IntrospectionEndpoint string
	RevocationEndpoint    string
}

Config is used to configure a client.

func Default

func Default(baseURI string) Config

Default will return a default configuration.

type Error

type Error struct {
	Status int
	Body   string
}

Error represents basic request errors.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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