oauth2

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package oauth2 holds utilities for bootstrapping an OAuth2 proxy from the metadata injected by a OAuth2 secret. Within an app, users can write:

middleware, err := oauth2.New(ctx, handler)

or

http.ListenAndServe(":8181", oauth2.NewOrDie(ctx, handler)))

This is modeled after the Bindings pattern.

Index

Constants

View Source
const (
	OAuth2ProxyCfg = "oauth2_proxy.cfg"
	IssuerName     = "oidc_issuer"
	ClientIDName   = "oidc_client_id"
)

Variables

This section is empty.

Functions

func Middleware

func Middleware(ctx context.Context, wrapped http.Handler, verifier *oidc.IDTokenVerifier) http.Handler

func New

func New(ctx context.Context, handler http.Handler) (http.Handler, error)

func NewOrDie

func NewOrDie(ctx context.Context, handler http.Handler) http.Handler

func NewProvider

func NewProvider(ctx context.Context, handler http.Handler) (http.Handler, error)

func ReadClientID

func ReadClientID(root string) (string, error)

func ReadIssuer

func ReadIssuer(root string) (string, error)

func StartOAuth2Proxy

func StartOAuth2Proxy(ctx context.Context) error

func WithAuthenticatedUser

func WithAuthenticatedUser(ctx context.Context, user *User) context.Context

Types

type User

type User struct {
	Issuer  string `json:"iss"`
	Subject string `json:"sub"`
	Email   string `json:"email"`
	Name    string `json:"name"`
}

func AuthenticatedUser

func AuthenticatedUser(ctx context.Context) *User

Jump to

Keyboard shortcuts

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