fakeissuer

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fakeissuer provides a minimal fake OIDC issuer for testing purpose.

Example:

  // Create a fake HTTP server and client.
  f, cleanup := fakehttp.New()
  defer cleanup()

  // Set the URL of the issuer to that of the fake HTTP server.
	 issuer = testkeys.Keys[testkeys.VisaIssuer0]
  issuer.ID = f.Server.URL
  i := stubissuer.New(f.Server.URL, issuer)
  f.Handler = i.Handler

  // Override the context to tell the package to use the fake HTTP client.
  // Any HTTP calls to issuer by oidc using ctx will be handled by the fake.
  ctx := oidc.ClientContext(context.Background(), f.Client)

Index

Constants

View Source
const (
	// OIDC URI.
	OIDC = "/oidc"

	// WellKnown URI.
	// https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml
	WellKnown = "/.well-known"

	// Configuration URI.
	Configuration = WellKnown + "/openid-configuration"

	// JWKS URI.
	JWKS = WellKnown + "/jwks"

	// Authorize URI.
	Authorize = "/authorize"

	// Token URI.
	Token = "/token"

	// UserInfo URI.
	UserInfo = "/userinfo"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GetJWKSResp

type GetJWKSResp = jose.JSONWebKeySet

GetJWKSResp is the type for GET JWKS Response

type GetWellKnownResp

type GetWellKnownResp struct {
	Issuer      string `json:"issuer"`
	AuthURL     string `json:"authorization_endpoint"`
	TokenURL    string `json:"token_endpoint"`
	JWKSURL     string `json:"jwks_uri"`
	UserInfoURL string `json:"userinfo_endpoint"`
}

GetWellKnownResp is the type for GET WellKnown Response.

type Issuer

type Issuer struct {
	URL              string
	Keys             []testkeys.Key
	GetWellKnownResp GetWellKnownResp
	GetJWKSResp      GetJWKSResp
}

Issuer is a fake OIDC issuer.

func New

func New(url string, keys ...testkeys.Key) *Issuer

New creates a new Issuer.

func (*Issuer) Handler

func (i *Issuer) Handler(req *http.Request) (body interface{}, err error)

Handler is the HTTP handler for the issuer.

Jump to

Keyboard shortcuts

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