plugin

package module
v0.1.1 Latest Latest
Warning

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

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

README

Traefik TLS headers plugin

Main workflow Go matrix workflow

Usage

This plugin will take TLS information from the client connection and write them to some headers.

middlewares:
  my-middleware:
    plugin:
      tlsheaders:
        headers:
          cipher: X-Tls-Cipher

Supported fields

  • cipher: The cipher used for the connection. See the docs CipherSuiteName for more information.
Configuration

Traefik static configuration must define the module name (as is usual for Go packages).

The following declaration (given here in YAML) defines a plugin:

File (YAML)
# Static configuration

experimental:
  plugins:
    tlsheaders:
      moduleName: github.com/RiskIdent/traefik-tls-headers-plugin
      version: v0.1.1
CLI
# Static configuration

--experimental.plugins.tlsheaders.moduleName=github.com/RiskIdent/traefik-tls-headers-plugin
--experimental.plugins.tlsheaders.version=v0.1.1
Kubernetes
# Dynamic configuration

apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: my-middleware
spec:
  plugin:
    tlsheaders:
      headers:
        cipher: X-Tls-Cipher
Test locally

In order to test the plugin locally, start the printheaders application:

make start_headers_reader

Then start Traefik with the plugin:

make testcontainer

The traefik test configuration is located in the testconfig directory.

And finally, make a request to the Traefik instance:

curl -sS https://localhost -k | grep X-Tls-Cipher

The response should contain the header(s) you set up.

X-Tls-Cipher: TLS_AES_128_GCM_SHA256

Credits

Icon made by https://www.flaticon.com/de/kostenloses-icon/tls-protokoll_4896619

Documentation

Overview

Package plugin contains the Traefik plugin for adding headers based on the TLS information

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New created a new TLSHeadersPlugin.

Types

type Config

type Config struct {
	Headers ConfigHeaders `json:"headers,omitempty"`
}

Config the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type ConfigHeaders

type ConfigHeaders struct {
	Cipher string `json:"cipher,omitempty"`
}

ConfigHeaders defines the headers to use for the different values.

type TLSHeadersPlugin

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

TLSHeadersPlugin is the main handler model for this Traefik plugin.

func (*TLSHeadersPlugin) ServeHTTP

func (a *TLSHeadersPlugin) 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