Skip to content

Commit

Permalink
Minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijkuit committed Sep 15, 2021
1 parent 5070704 commit 17504f4
Show file tree
Hide file tree
Showing 71 changed files with 21,351 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
displayName: "Azure JWT token validation"
import: github.com/dkijkuit/azurejwttokenvalidation
summary: "Validates JWT tokens generated by Azure and verifies the claims. Allows payload validation based on Azure roles as well."
iconPath: icon/microsoft_azure_logo_icon.png
testData:
audience: audience_test
issuer: "https://issuer.test"
keysurl: "https://jwks.keys"
matchallroles: true
roles:
- Test.Role.1
- Test.Role.2
type: middleware
31 changes: 31 additions & 0 deletions dynamic-dev-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Dynamic configuration

http:
routers:
my-router:
rule: Path(`/whoami`)
service: service-whoami
entryPoints:
- http
middlewares:
- azure-jwt-check

services:
service-whoami:
loadBalancer:
servers:
- url: http://127.0.0.1:5000

middlewares:
azure-jwt-check:
plugin:
dev:
keysurl: "https://jwks.keys"
issuer: "https://issuer.test"
audience:
- "audience"
roles:
- Test.Role.1
- Test.Role.2
matchallroles: true
loglevel: "DEBUG"
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/dkijkuit/azurejwttokenvalidation

go 1.16

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
15 changes: 15 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Binary file added icon/microsoft_azure_logo_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions jwt-models.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package azurejwttokenvalidation

import (
"encoding/json"
)

type AzureJwt struct {
Header AzureJwtHeader
Payload Claims
Signature []byte
RawToken []byte
RawPayload []byte
}

type AzureJwtHeader struct {
Alg string `json:"alg"`
Kid string `json:"kid"`
Typ string `json:"typ"`
}

type Claims struct {
Iat json.Number `json:"iat"`
Exp json.Number `json:"exp"`
Iss string `json:"iss"`
Aud string `json:"aud"`
Sub string `json:"sub"`
Roles []string `json:"roles"`
}
1 change: 1 addition & 0 deletions plugins-storage/archives/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
25 changes: 25 additions & 0 deletions static-dev-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Static configuration
api:
dashboard: true
insecure: true

pilot:
token: <YOUR_TOKEN>

log:
level: DEBUG

experimental:
devPlugin:
goPath: /home/david/go/
moduleName: github.com/dkijkuit/azurejwttokenvalidation

entryPoints:
http:
address: ":4000"
forwardedHeaders:
insecure: true

providers:
file:
filename: dynamic-dev-config.yml
Loading

0 comments on commit 17504f4

Please sign in to comment.