# HG changeset patch # User Kim Alvefur # Date 1678970749 -3600 # Node ID 2aebd9bf02fcbf7f4a8cf7a20bd2fd8893bb42d1 # Parent bb6a98a7b0b4127d75610fbbfbba69fc51a883e4 util.sasl.oauthbearer: Adjust parsing of GS2 to allow lack of authzid Partly copied from util.sasl.scram and then reduced a bit. diff -r bb6a98a7b0b4 -r 2aebd9bf02fc util/sasl/anonymous.lua --- a/util/sasl/anonymous.lua Thu Mar 16 13:20:19 2023 +0100 +++ b/util/sasl/anonymous.lua Thu Mar 16 13:45:49 2023 +0100 @@ -33,8 +33,8 @@ local username; repeat username = generate_random_id():lower(); - until self.profile.anonymous(self, username, self.realm); - self.username = username; + self.username = username; + until self.profile.anonymous(self, username, self.realm, message); return "success" end diff -r bb6a98a7b0b4 -r 2aebd9bf02fc util/sasl/oauthbearer.lua --- 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