Diff

util/sasl/oauthbearer.lua @ 12940:2aebd9bf02fc

util.sasl.oauthbearer: Adjust parsing of GS2 to allow lack of authzid Partly copied from util.sasl.scram and then reduced a bit.
author Kim Alvefur <zash@zash.se>
date Thu, 16 Mar 2023 13:45:49 +0100
parent 12938:055b03d3059b
child 12951:4cc0785f960e
line wrap: on
line diff
--- a/util/sasl/oauthbearer.lua	Thu Mar 16 13:20:19 2023 +0100
+++ b/util/sasl/oauthbearer.lua	Thu Mar 16 13:45:49 2023 +0100
@@ -11,10 +11,11 @@
 		return "failure", "not-authorized";
 	end
 
-	local gs2_authzid, kvpairs = message:match("n,a=([^,]+),(.+)$");
-	if not gs2_authzid then
+	local gs2_header, kvpairs = message:match("^(n,[^,]*,),(.+)$");
+	if not gs2_header then
 		return "failure", "malformed-request";
 	end
+	local gs2_authzid = gs2_header:match("^[^,]*,a=([^,]*),$");
 
 	local auth_header;
 	for k, v in kvpairs:gmatch("([a-zA-Z]+)=([\033-\126 \009\r\n]*)\001") do