traefik_token_auth

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 4 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.0

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
          # (bcrypt) plaintext: pass, cost: 5
          hashedToken: $2y$05$aNQMGzpGsz5KLKTJlXsSm.cHv6wMJi/qBEyin4xRlZlMvLgMuPOiS

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
}

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