Skip to content

Conversation

emelialei88
Copy link
Collaborator

This PR includes:

  • Updated plugin interface in mqbplug
  • Configurations for plugins in mqbcfg
  • mqbauthn package that controls the plugin and includes built-in plugins

@emelialei88 emelialei88 requested a review from a team as a code owner October 20, 2025 18:55
@emelialei88 emelialei88 marked this pull request as draft October 20, 2025 19:21
@emelialei88 emelialei88 marked this pull request as ready for review October 20, 2025 20:32
Copy link
Collaborator

@678098 678098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have some comments.
The most important ones are regarding breaking changes in plugins API (bslstl::StringRef -> bsl::string_view)
I cannot build everything on Solaris/Linux due to these issues


/// Return the name of the plugin.
virtual bslstl::StringRef name() const = 0;
virtual bsl::string_view name() const = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change.
All other plugins still use bslstl::StringRef and cannot inherit from bsl::string_view one
Even if we update them, we will lose compatibility with older versions of the plugins. It might result in strange crashes due to incompatible API

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To deal with this, I propose to

  1. Keep the original bslstl::StringRef declaration
  2. Add a new one virtual virtual bsl::string_view name() const { return static_cast<bslstl::StringRef>(name()); }
    With the default implementation, it will be compatible with older plugins.
    We are free to gradually add bsl::string_view implementation in plugins and eventually remove bslstl::StringRef one.

Alternatively we can revert this change to remove possible risks
@hallfox what do you think?

Copy link
Collaborator

@678098 678098 Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in another PR #993


// Start the authenticator
if (int status = authenticator->start(errorStream)) {
BMQTSK_ALARMLOG_ALARM("#AUTHENTICATION")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Authn Controller makes decision to print an alarm, should it also print it on other failures in this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean if we should ALARM on other errors in this function? I'm actually not fully sure what are the scenarios where we trigger an ALARM.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can move forward with this for now, can discuss the alarms separately.

Copy link
Collaborator

@678098 678098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a few ideas about logs

678098
678098 previously approved these changes Oct 22, 2025
Comment on lines +306 to +309
bsl::string anonMechanism = bsl::string(AnonAuthenticator::k_MECHANISM,
d_allocator_p);

if (d_authenticators.find(anonMechanism) != d_authenticators.cend()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bsl::string anonMechanism = bsl::string(AnonAuthenticator::k_MECHANISM,
d_allocator_p);
if (d_authenticators.find(anonMechanism) != d_authenticators.cend()) {
if (d_authenticators.find(AnonAuthenticator::k_MECHANISM) != d_authenticators.cend()) {

Possible to avoid constructing tmp string

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would cause a compiler error since bsl::unordered_map<bsl::string, AuthenticatorMp> doesn't accept bsl::string_view as the parameter to find.

Comment on lines 339 to 341
// If no authenticators are configured, use AnonAuthenticator for
// anonymous pass authentication
if (d_authenticators.empty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If no authenticators are configured, use AnonAuthenticator for
// anonymous pass authentication
if (d_authenticators.empty()) {
if (!d_authenticators.empty()) {
// Have authenticators, nothing to do
return 0;
}
// If no authenticators are configured, use AnonAuthenticator for
// anonymous pass authentication

Not strictly necessary to do, but I would make an early return here to reduce indentation of the following code.
Your original option is also good: it only has 1 return, not 2.

If the body of if-then has more lines or if there are even more layers of indentation, early return looks better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it might help the reader.
Consider the following code:

void foo(bool flag) {
    if (flag) {
        // 200 lines here
    }
    // nothing in the end
}

If a reader sees if like this, they must scroll down 200 lines to see the end of this function just to know if there is any more processing if flag == false.

Compared to this:

void foo(bool flag) {
    if (!flag) return;
    // 200 lines here
}

The reader knows that after the first line (with early return) there are no instructions for flag == false

Another case:

void foo(bool flag) {
    if (flag) {
        // 100 lines here
    }
    if (somethingElse()) {
        // 100 lines here
    }
    // nothing in the end
}

In this case, it is not even enough to scroll down 200 lines, the reader has to notice the end of the current if structure and start of another structure not related to flag. This might be solved by folding structures in IDE, however, these are extra mouse clicks

if (!d_isStarted) {
return; // RETURN
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BALL_LOG_INFO << "Stopping AuthenticationController";

If we log starting, we might log stopping as well

errorDescription
<< "AuthenticationController: authentication mechanism '"
<< normMech << "' not supported.";
return (rc * 10 + rc_MECHANISM_NOT_SUPPORTED);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rc == e_SUCCESS here, might simplify:

Suggested change
return (rc * 10 + rc_MECHANISM_NOT_SUPPORTED);
return rc_MECHANISM_NOT_SUPPORTED;

We already have functions where we mix const * rc + enum with just rc or enum, this for example:

Comment on lines 446 to 447
int rc = rc_SUCCESS;
bmqu::MemOutStream errorStream(d_allocator_p);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int rc = rc_SUCCESS;
bmqu::MemOutStream errorStream(d_allocator_p);

Possible to move closer to authenticate below.
This is a "minimal scope" principle for definition of variables.
Minimal scope means that a reader has to keep in mind less variables at a point of time, making reading the code easier. Also, sometimes (rarely) defining variables in the least scope possible prevents others from misusing these variables later

<< "authenticating with mechanism '" << normMech << "'"
<< " (authenticator: '" << authenticator->name()
<< "')";
rc = authenticator->authenticate(errorStream, result, input);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rc = authenticator->authenticate(errorStream, result, input);
bmqu::MemOutStream errorStream(d_allocator_p);
const int rc = authenticator->authenticate(errorStream, result, input);

@678098
Copy link
Collaborator

678098 commented Oct 22, 2025

IT failure is unrelated mqbu_exit.cpp:124 #EXIT Terminating BMQBRKR with error 'STORAGE_OUT_OF_SYNC'
Will be fixed here: #984

678098
678098 previously approved these changes Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants