Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions Library/AppSrc/JWT/JWT.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,52 @@ Class cBaseJsonWebToken is a cJsonObject
Function_Return (MemberValue(Self, "sub"))
End_Function

//If the audience is a space separated string, then it would be a JSON Array, otherwise just a String.
{ MethodType=Property }
Procedure Set Audience String sValue
Send SetMemberValue "aud" jsonTypeString sValue
String sTempString
Boolean bSuccess
Handle hoTempJson
String[] saAudience

If (Pos(' ', sValue)) Begin
Move (StrSplitToArray(sValue, " ")) to saAudience
If (SizeOfArray(saAudience) > 0) Begin
Get StrJoinFromArray saAudience '","' to sTempString
Move ('["' - sTempString - '"]') to sTempString
Get Create (RefClass(cJsonObject)) to hoTempJson
Send InitializeJsonType of hoTempJson jsonTypeArray
Get ParseString of hoTempJson sTempString to bSuccess
If (bSuccess) ;
Send SetMember "aud" hoTempJson
Send Destroy of hoTempJson
End
End
Else ;
Send SetMemberValue "aud" jsonTypeString sValue
End_Procedure
{ MethodType=Property }
Function Audience Returns String
Integer iJsonTypeMember
String sMemberValue
String[] saMemberValue
Handle hoMember

If (not(HasMember(Self, "aud"))) Function_Return ""
Function_Return (MemberValue(Self, "aud"))
Get MemberValue "aud" to sMemberValue

Get MemberJsonType "aud" to iJsonTypeMember
If (iJsonTypeMember = jsonTypeArray) Begin
Move (Replace('[ "', sMemberValue, '')) to sMemberValue
Move (Replace('" ]', sMemberValue, '')) to sMemberValue
Get StrSplitToArray sMemberValue '", "' to saMemberValue
Function_Return (StrJoinFromArray(saMemberValue, ' '))
End
Else If (iJsonTypeMember = jsonTypeString) Begin
Function_Return sMemberValue
End
Else ;
Function_Return ""
End_Function

{ MethodType=Property }
Expand Down
17 changes: 10 additions & 7 deletions Library/AppSrc/JWT/l8w8jwt2_mixin.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ Class cL8w8jwt_Mixin is a Mixin
Move (AddressOf(sIss)) to stl8w8jwt_encoding_params.iss
Move (SizeOfString(sIss)) to stl8w8jwt_encoding_params.iss_length
End
//Aud
If (HasMember(hoJsonWebToken, 'aud')) Begin
Get MemberValue of hoJsonWebToken 'aud' to sAud
Move (AddressOf(sAud)) to stl8w8jwt_encoding_params.aud
Move (SizeOfString(sAud)) to stl8w8jwt_encoding_params.aud_length
End
//JTI
If (HasMember(hoJsonWebToken, 'jti')) Begin
Get MemberValue of hoJsonWebToken 'jti' to sJti
Expand Down Expand Up @@ -204,8 +198,17 @@ Class cL8w8jwt_Mixin is a Mixin
Move (AddressOf(pJWTResult)) to stl8w8jwt_encoding_params.out
Move (AddressOf(iSizeOfJWTResult)) to stl8w8jwt_encoding_params.out_length

Move (StrSplitToArray("sub,iss,iat,exp,nbf", ',')) to saBlacklistMembers
//Aud
If (HasMember(hoJsonWebToken, 'aud')) Begin
Get MemberValue of hoJsonWebToken 'aud' to sAud
If (not(Pos('[', sAud) > 0 or Pos(']', sAud) > 0)) Begin
Move (AddressOf(sAud)) to stl8w8jwt_encoding_params.aud
Move (SizeOfString(sAud)) to stl8w8jwt_encoding_params.aud_length
Move 'aud' to saBlacklistMembers[SizeOfArray(saBlacklistMembers)]
End
End
//Additional claims
Move (StrSplitToArray("sub,iss,aud,iat,exp,nbf", ',')) to saBlacklistMembers
Move (SortArray(saBlacklistMembers)) to saBlacklistMembers
Move 0 to iClaimsCounter

Expand Down