httpserver

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// JwtCheckExp will determine if we need to verify if the token is expired or not
	JwtCheckExp = true
	// JwtIssuer is the url where we can retrieve a set of public keys to verify rsa based tokens with
	JwtIssuer = "http://localhost/.well-known/jwks.json"
	// JwtOutboundHeader is the name of header the parsed token claims will be inserted into
	JwtOutboundHeader = "X-JWT-PAYLOAD"
	// AllowBasicAuthPassThrough will allow requests with a basic auth authorization header to be passed through
	AllowBasicAuthPassThrough = false
	// AllowBasicAuthHeaders specifies the header to extract the basic auth request from
	AllowBasicAuthHeaders = []string{"Authorization"}
	// AllowBasicAuthPathRegex allows us to only allow a basic auth pass through for requests with a certain path
	AllowBasicAuthPathRegex = regexp.MustCompile(`^\/.*`)
	// NewErrorMessageRegex is used to apply new error structure only to specific endpoints (see bcab0f12220b1e26c6dad10ee6aa1825172051ab). This is for backward compatibility.
	NewErrorMessageRegex = regexp.MustCompile(`^\/.*`)
	// BasicAuthRegex is for checking if a basic auth request is formatted correctly
	BasicAuthRegex = regexp.MustCompile(`^Basic\ .*`)
)

Functions

This section is empty.

Types

type Error added in v0.4.0

type Error struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

Error is returned in ErrorMsg

type ErrorMsg added in v0.4.0

type ErrorMsg struct {
	StatusCode int     `json:"status_code,omitempty"`
	Errors     []Error `json:"errors"`
}

ErrorMsg is returned on unauthorized requests

type Server

type Server struct {
	Issuer string
	JwkSet jose.JSONWebKeySet
}

Server needs to know about the Issuer url to verify tokens against

func NewServer

func NewServer(issuer string) *Server

NewServer creates a new Server object with the jwkset retrieved from the issuer

func (*Server) DecodeHTTPHandler

func (server *Server) DecodeHTTPHandler(w http.ResponseWriter, r *http.Request)

DecodeHTTPHandler will try to extract the bearer token found in the Authorization header of each request and verify it

func (*Server) Start

func (server *Server) Start(port int) error

Start accepting requests and decoding Authorization headers

Jump to

Keyboard shortcuts

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