diff --git a/Library/AppSrc/JWT/JWT.pkg b/Library/AppSrc/JWT/JWT.pkg index 1dc7bae..55372fb 100644 --- a/Library/AppSrc/JWT/JWT.pkg +++ b/Library/AppSrc/JWT/JWT.pkg @@ -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 } diff --git a/Library/AppSrc/JWT/l8w8jwt2_mixin.pkg b/Library/AppSrc/JWT/l8w8jwt2_mixin.pkg index 9688a4a..a383b20 100644 --- a/Library/AppSrc/JWT/l8w8jwt2_mixin.pkg +++ b/Library/AppSrc/JWT/l8w8jwt2_mixin.pkg @@ -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 @@ -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