Skip to content

Commit ae38e7b

Browse files
authored
Merge pull request #35 from agilezebra/34-log-output-of-plugin-only-showing-3-jwks-entries-even-when-jkws-endpoint-has-more-than-3-entries
strip padding; add error messages for bad decoding
2 parents 07bf61d + 6dac4c6 commit ae38e7b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ experimental:
1919
plugins:
2020
jwt:
2121
moduleName: github.com/agilezebra/jwt-middleware
22-
version: v1.2.6
22+
version: v1.2.7
2323
```
2424
1b. or with command-line options:
2525
2626
```yaml
2727
command:
2828
...
2929
- "--experimental.plugins.jwt.modulename=github.com/agilezebra/jwt-middleware"
30-
- "--experimental.plugins.jwt.version=v1.2.6"
30+
- "--experimental.plugins.jwt.version=v1.2.7"
3131
```
3232
3333
2) Configure and activate the plugin as a middleware in your dynamic traefik config:

jwks.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import (
1010
"encoding/base64"
1111
"encoding/json"
1212
"fmt"
13+
"log"
1314
"math/big"
1415
"net/http"
16+
"strings"
1517
)
1618

1719
// JSONWebKey is a JSON web key returned by the JWKS request.
@@ -63,12 +65,14 @@ func FetchJWKS(url string, client *http.Client) (map[string]interface{}, error)
6365
switch jwk.Kty {
6466
case "RSA":
6567
{
66-
nBytes, err := base64.RawURLEncoding.DecodeString(jwk.N)
68+
nBytes, err := base64.RawURLEncoding.DecodeString(strings.TrimRight(jwk.N, "="))
6769
if err != nil {
70+
log.Printf("error decoding N: %v for kid: %v", err, jwk.Kid)
6871
break
6972
}
70-
eBytes, err := base64.RawURLEncoding.DecodeString(jwk.E)
73+
eBytes, err := base64.RawURLEncoding.DecodeString(strings.TrimRight(jwk.E, "="))
7174
if err != nil {
75+
log.Printf("error decoding E: %v for kid: %v", err, jwk.Kid)
7276
break
7377
}
7478
keys[jwk.Kid] = &rsa.PublicKey{

0 commit comments

Comments
 (0)