Skip to content

Commit

Permalink
security: Refactor gssapi_authenticator 5/5
Browse files Browse the repository at this point in the history
Eliminate `finish`, reset `impl` when authentication is complete.

Signed-off-by: Ben Pope <[email protected]>
  • Loading branch information
BenPope committed Jan 26, 2023
1 parent e7e76f1 commit 2beefd1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/v/security/gssapi_authenticator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class gssapi_authenticator::impl {
state_result<bytes> ssfcap(bytes_view);
state_result<bytes> ssfreq(bytes_view);
state_result<void> check();
void finish();
void
fail_impl(OM_uint32 maj_stat, OM_uint32 min_stat, std::string_view msg);
template<typename... Args>
Expand Down Expand Up @@ -172,6 +171,15 @@ gssapi_authenticator::gssapi_authenticator(
gssapi_authenticator::~gssapi_authenticator() = default;

ss::future<result<bytes>> gssapi_authenticator::authenticate(bytes auth_bytes) {
if (!_impl) {
vlog(
seclog.warn,
"authenticate received after handshake complete {} bytes",
_state,
auth_bytes.size());
co_return errc::invalid_gssapi_state;
}

vlog(
seclog.trace,
"gss {} authenticate received {} bytes",
Expand All @@ -187,6 +195,7 @@ ss::future<result<bytes>> gssapi_authenticator::authenticate(bytes auth_bytes) {
if (_state == state::complete) {
_principal = co_await _worker.submit(
[this]() { return _impl->principal(); });
_impl.reset();
}
co_return std::move(res.result);
}
Expand Down Expand Up @@ -400,7 +409,7 @@ gssapi_authenticator::impl::ssfreq(bytes_view auth_bytes) {

bytes ret{};
vlog(seclog.trace, "gss {} sending {} bytes", _state, ret.size());
finish();
_state = state::complete;
return {_state, ret};
}

Expand Down Expand Up @@ -474,12 +483,6 @@ gssapi_authenticator::impl::check() {
return {_state, outcome::success()};
}

void gssapi_authenticator::impl::finish() {
_context.reset();
_server_creds.reset();
_state = state::complete;
}

void gssapi_authenticator::impl::fail_impl(
OM_uint32 maj_stat, OM_uint32 min_stat, std::string_view msg) {
if (maj_stat != 0 || min_stat != 0) {
Expand Down

0 comments on commit 2beefd1

Please sign in to comment.