Skip to content

Commit

Permalink
Update documentation and testing
Browse files Browse the repository at this point in the history
Signed-off-by: Georges-Etienne Legendre <[email protected]>
  • Loading branch information
legege committed Mar 18, 2023
1 parent aca2225 commit e29de82
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ JWT Validation Middleware is a middleware plugin for [Traefik](https://github.co
Start with command
```yaml
command:
- "--experimental.plugins.jwt-middleware.modulename=github.com/legege/jwt-middleware"
- "--experimental.plugins.jwt-middleware.version=v0.1.0"
- "--experimental.plugins.jwt-validation-middleware.modulename=github.com/legege/jwt-validation-middleware"
- "--experimental.plugins.jwt-validation-middleware.version=v0.1.0"
```
Activate plugin in your config
Expand All @@ -18,8 +18,8 @@ http:
middlewares:
my-jwt-middleware:
plugin:
jwt-middleware:
secret: SECRET
jwt-validation-middleware:
secret: ThisIsMyVerySecret
payloadHeader: X-Jwt-Payload
authQueryParam: authToken
authCookieName: authToken
Expand All @@ -31,4 +31,19 @@ Use as docker-compose label
- "traefik.http.routers.my-service.middlewares=my-jwt-middleware@file"
```
Forked from https://github.com/23deg/jwt-middleware
## Initial release
Forked from https://github.com/23deg/jwt-middleware
## Local testing
```
docker-compose -f docker-compose.test.yml up
```

```
JWT_TOKEN=...
curl -H "Host: test.host.local" "http://localhost:80/?authToken=$JWT_TOKEN" -i
curl -H "Host: test.host.local" --cookie "authToken=$JWT_TOKEN" "http://localhost:80/" -i
curl -H "Host: test.host.local" -H "Authorization: Bearer $JWT_TOKEN" "http://localhost:80/" -i
```
44 changes: 44 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3.3"

networks:
traefik-proxy:

volumes:
traefik-proxy:

services:
traefik-proxy:
image: traefik:v2.9
restart: unless-stopped
networks:
- traefik-proxy
security_opt:
- no-new-privileges:true
command:
- "--log.level=DEBUG"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik-proxy"
- "--entrypoints.web.address=:80"
- "--entrypoints.traefik.address=:9000"
- "--api.dashboard=true"
- "--api.insecure=true"
- "--experimental.localPlugins.jwt-validation-middleware.moduleName=github.com/legege/jwt-validation-middleware"
ports:
- "80:80"
- "127.0.0.1:9000:9000"
volumes:
- "traefik-proxy:/data"
- ".:/plugins-local/src/github.com/legege/jwt-validation-middleware/"
- "/var/run/docker.sock:/var/run/docker.sock:ro"

whoami:
image: traefik/whoami
networks:
- traefik-proxy
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`test.host.local`)"
- "traefik.http.routers.whoami.middlewares=test-jwt"
- "traefik.http.middlewares.test-jwt.plugin.jwt-validation-middleware.secret=ThisIsMyVerySecret"
2 changes: 1 addition & 1 deletion jwt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jwt_middleware
package jwt_validation_middleware

import (
"context"
Expand Down

0 comments on commit e29de82

Please sign in to comment.