x-ream / traefik-plugin-jwt-antpath

Traefik plugin of jwt, antpath

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JWT AntPath

workflow build

JWT AntPath is a middleware plugin for Traefik which verify JWT excludes configured path, and add payload to header

Limited support AntPath for interpreter plugin

  • AntPath only support / as separator
  • AntPath only support * as wildcard
  • AntPath only support ** as recursive wildcard

Support

          paths:
            - /base/app-home/**
            - /*/doc/**
            - /foo/*/doc/**
            - /foo/* 

Not support: contains(path, "**") && !endWith2Star

          paths:
            - /**/app-home/**
            - /**/app-home/*
            - /**/doc/**
            - /**/doc/*
            - /foo/**/doc/**

Configuration

Traefik helm charts values.yml

experimental:
  enabled: true
  plugins:
    jwtantpath:
      moduleName: "github.com/x-ream/traefik-plugin-jwt-antpath"
      version: "v0.1.0"

K8s middleware

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: my-jwtantpath
spec:
  plugin:
    jwtantpath:
      headerKey: "Authorization"
      secureKey: "my-secret-key"
      paths:
        - /base/app-home/**

App ingress values.yml

ingress:
  enabled: true
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: web
    traefik.ingress.kubernetes.io/router.middlewares: test-my-jwtantpath@kubernetescrd,test-strip-prefix@kubernetescrd
  ingressClassName: traefik
  hosts:
    - host: myapp.com
      paths:
        - path: /base
          pathType: "Prefix"

Other configuration, not for k8s

Static

[experimental.plugins.jwtantpath]
    modulename = "github.com/x-ream/traefik-plugin-jwt-antpath"
    version = "v0.1.0"

Dynamic

To configure the JWT AntPath plugin you should create a middleware in your dynamic configuration as explained here. The following example creates and uses the JWT AntPath middleware plugin to verify token and add payload to header of all HTTP requests exclude path starting with /foo.

[http.routers]
  [http.routers.my-router]
    rule = "Host(`localhost`)"
    middlewares = ["jwtantpath"]
    service = "my-service"

# Very jwt exclude all paths starting with /foo
[http.middlewares]
  [http.middlewares.foo.plugin.jwtantpath]
    secureKey = "my-secret-key"
    headerKey =  "Authorization"  
    paths = ["/foo/**", "/*/goods/**"]

[http.services]
  [http.services.my-service]
    [http.services.my-service.loadBalancer]
      [[http.services.my-service.loadBalancer.servers]]
        url = "http://127.0.0.1"

About

Traefik plugin of jwt, antpath

License:Apache License 2.0


Languages

Language:Go 99.0%Language:Makefile 1.0%