-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added padding for base64 in order to use strict base64 decoding of Zn…
…. Added explicity conversion between byte array and string. This make it work in pharo7
- Loading branch information
Showing
6 changed files
with
20 additions
and
6 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...Token-Core.package/JWSCompactSerializer.class/instance/materialize.key.checkSignature..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
reading | ||
materialize: aString key: aKeyString checkSignature: checkSignature | ||
| parts header jws | | ||
parts := $. split: aString. | ||
header := JWSHeader fromJson: (parts at: 1) base64Decoded. | ||
parts := $. split: aString. | ||
header := JWSHeader fromJson: (parts at: 1) base64Padded base64Decoded asString. | ||
jws := JsonWebSignature new | ||
key: aKeyString; | ||
setProtectedHeader: header. | ||
checkSignature ifTrue: [ | ||
jws checkSignature: parts ]. | ||
^ jws payload: (JWTClaimsSet fromJson: parts second base64Decoded) | ||
^ jws payload: (JWTClaimsSet fromJson: parts second base64Padded base64Decoded asString) |
2 changes: 1 addition & 1 deletion
2
source/JSONWebToken-Core.package/JWSCompactSerializer.class/instance/writeHeader..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
as yet unclassified | ||
writeHeader: aHeader | ||
stream nextPutAll: aHeader asJson base64Encoded | ||
stream nextPutAll: aHeader asJson asByteArray base64Encoded |
2 changes: 1 addition & 1 deletion
2
source/JSONWebToken-Core.package/JWSCompactSerializer.class/instance/writePayload..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
writing | ||
writePayload: anObject | ||
stream nextPutAll: anObject asJson base64Encoded | ||
stream nextPutAll: anObject asJson asByteArray base64Encoded |
2 changes: 1 addition & 1 deletion
2
source/JSONWebToken-Core.package/JsonWebSignature.class/instance/checkSignature..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
signature | ||
checkSignature: parts | ||
((self signatureFor: ($. join: { parts first . parts second })) = parts third base64Decoded asByteArray) ifFalse: [ | ||
((self signatureFor: ($. join: { parts first . parts second })) = parts third base64Padded base64Decoded) ifFalse: [ | ||
Error signal: 'signature does not match' ]. |
11 changes: 11 additions & 0 deletions
11
source/JSONWebToken-Core.package/String.extension/instance/base64Padded.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*JSONWebToken-Core | ||
base64Padded | ||
| paddedString | | ||
paddedString := ((self size \\ 4) = 0) | ||
ifTrue: [ self ] | ||
ifFalse: [ | ||
String streamContents: [ :stream | | ||
stream nextPutAll: self. | ||
(4 - (self size \\ 4)) timesRepeat: [ | ||
stream nextPut: $= ] ] ]. | ||
^ paddedString |
3 changes: 3 additions & 0 deletions
3
source/JSONWebToken-Core.package/String.extension/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name" : "String" | ||
} |