Re: [PATCH v5 1/3] send-email: implement SMTP bearer authentication
- From
Julian Swagemakers <julian@swagemakers.org>
- Date
- Apr 25, 2025, 06:19 UTC
- Message-ID
- <D9FI2S0NSC40.28VZMYOR6M8DO@swagemakers.org>
- In-Reply-To
- <PN3PR01MB9597922F495805CA728A0B31B8852@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
On Thu Apr 24, 2025 at 8:22 PM CEST, Aditya Garg wrote:
Show 12 quoted lines
> I saw the code of perl-authen-sasl and I miserably failed in porting > the logic used here to the repo. > > Perl is not something I am very strong at, so not really feasible for > me to work ahead. I do was able to return the formatted base64 encoded > string as per the logic, but still I got authentication issues. > Currently I aim to have git-send-email working, and a review from an > experienced person is needed. > > I would be happy to be able to test any proposed patch though. > > Julian, you might be interested here?
I fear I'm also a rookie when it comes to perl, but with your code and the comment from Erik I managed to get it working. client_start and client_step have to look like this:
sub client_start {
my $self = shift;
$self->{stage} = 0;
# Generate the XOAUTH2 authentication string
my $username = $self->_call('user');
my $token = $self->_call('pass'); # OAuth 2.0 access token
my $auth_string = "user=$username\001auth=Bearer $token\001\001";
return $auth_string
}sub client_step {
my ($self, $challenge) = @_; my $stage = ++$self->{stage}; if ($stage == 1) {
# Handle authentication failure by sending a dummy request
return "\001"
} else {
return $self->set_error("Invalid sequence");
}
}Aditya, do you want to create a pull request on perl-authen-sasl, or should I?
Regards Julian