From 39048302915ac902c5b515eb9c11bece258cd795 Mon Sep 17 00:00:00 2001 From: hasinthaindrajee Date: Mon, 26 Aug 2019 14:43:48 +0530 Subject: [PATCH] Use Base64Url encoding instead of Base64 encoding for jwts --- components/api/idp/tokens.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/api/idp/tokens.bal b/components/api/idp/tokens.bal index 795536c..420132e 100644 --- a/components/api/idp/tokens.bal +++ b/components/api/idp/tokens.bal @@ -109,7 +109,7 @@ public function extractSubject(string jwt) returns error | string{ log:printDebug("Decoding jwt token body :" + jwt); string[] split_string = jwt.split("\\."); // Split the string string base64EncodedBody = split_string[1]; // Payload part - byte[] bodyBytes = check encoding:decodeBase64(base64EncodedBody); + byte[] bodyBytes = check encoding:decodeBase64Url(base64EncodedBody); string body = encoding:byteArrayToString(bodyBytes, encoding = "utf-8"); log:printDebug("Decoded jwt token body :" + body); io:StringReader sr = new(body, encoding = "UTF-8");