headerhasher

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

HeaderHasher Traefik middleware

This is a simple middleware that looks for a specific HTTP request header and if found attaches its sha256 value as another header.

An example practical application of this would be custom rate limiting routes for specific authorisation headers. You don't want to keep the plaintext authorization token value together with the rest of ingress routes configuration. This middleware allows to safely use it's hash instead of keeping the token secret.

Usage

TODO

Configuration

TODO

Documentation

Overview

Package headerhasher is a traefik middleware that looks for a specified input header and attaches its sha256 hash as a new header.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(_ context.Context, next http.Handler, config *Config, _ string) (http.Handler, error)

New creates a new HeaderHasher plugin.

Types

type Config

type Config struct {
	InputHeader  string `json:"inputHeader,omitempty"`
	OutputHeader string `json:"outputHeader,omitempty"`
}

Config holds the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type HeaderHasher

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

HeaderHasher represents the plugin which looks for a header named `inputHeader` and if found calculates sha256 of its value and attaches it as `outputHeader`.

func (*HeaderHasher) ServeHTTP

func (a *HeaderHasher) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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