traefik_token_auth

package module
v0.1.1 Latest Latest
Warning

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

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

README

traefik-token-auth

Configuration

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

# Static configuration

experimental:
  plugins:
    traefik-token-auth:
      moduleName: github.com/0xanonymeow/traefik-token-auth
      version: v0.1.1

Here is an example of a file provider dynamic configuration (given here in YAML), where the interesting part is the http.middlewares section:

# Dynamic configuration

http:
  routers:
    my-router:
      rule: host(`demo.localhost`)
      service: service-foo
      entryPoints:
        - web
      middlewares:
        - tokenAuth@docker

  services:
   service-foo:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:80

  middlewares:
    tokenAuth:
      plugin:
        traefik-token-auth:
          headerField: X-Api-Token
          removeHeader: true
          algorithm: sha256
          hashedToken: d74ff0ee8da3b9806b18c877dbf29bbde50b5bd8e4dad7a3a725000feb82e8f1

Documentation

Overview

Package traefik_token_auth .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New created a new token auth plugin.

Types

type Config

type Config struct {
	HeaderField  string
	HashedToken  string
	RemoveHeader bool
	Algorithm    string
}

Config the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type TokenAuth

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

TokenAuth a traefik_token_auth plugin.

func (*TokenAuth) ServeHTTP

func (ta *TokenAuth) 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