@@ -7,15 +7,13 @@ import (
77 "time"
88)
99
10- var decodePaddingAllowed bool
1110
12- // SetDecodePadding will switch the codec used for encoding/decoding JWTs respectively. Note that the JWS RFC7515
11+ // DecodePaddingAllowed will switch the codec used for encoding/decoding JWTs respectively. Note that the JWS RFC7515
1312// states that the tokens will utilize a Base64url encoding with no padding. Unfortunately, some implementations
1413// of JWT are producing non-standard tokens, and thus require support for decoding. Note that this is a global
1514// variable, and updating it will change the behavior on a package level, and is also NOT go-routine safe.
16- func SetDecodePadding (setPadding bool ) {
17- decodePaddingAllowed = setPadding
18- }
15+ // To use the non-recommended decoding, set this boolean to `true` prior to using this package.
16+ var DecodePaddingAllowed bool
1917
2018// TimeFunc provides the current time when parsing token to validate "exp" claim (expiration time).
2119// You can override it to use another time value. This is useful for testing or if your
@@ -122,7 +120,7 @@ func EncodeSegment(seg []byte) string {
122120// Deprecated: In a future release, we will demote this function to a non-exported function, since it
123121// should only be used internally
124122func DecodeSegment (seg string ) ([]byte , error ) {
125- if decodePaddingAllowed {
123+ if DecodePaddingAllowed {
126124 if l := len (seg ) % 4 ; l > 0 {
127125 seg += strings .Repeat ("=" , 4 - l )
128126 }
0 commit comments