Skip to content

Web Basic authentication not creating template user #4840

@robwdwd

Description

@robwdwd

Describe the bug

Currently on cacti 1.2.21 and this seems to have broken web basic authentication. When a user authenticates with web basic the template user is not used to copy the user because the auth method is being reset and cacti us treating it as a local user. This does not affect users logging in with an existing account.

To Reproduce

This happens every time a new user logs in without an existing account, that must be copied from the template user.

Expected behavior

User is created on first login from template user.

Additional context

I tracked the issue down to this bit of code in auth_login.php. $frv_realm is set here, but I am presuming since web basic auth won't have a form this will use the default 0.

$frv_realm     = get_nfilter_request_var('realm', 0); // The dropdown value for realm

It then hits this bit of code which resets $auth_method to local because $auth_method = 2 and $frv_realm = 0

if (get_nfilter_request_var('action') == 'login' || $auth_method == 2) {
  if ($auth_method >= 2 && $frv_realm <= 1) {
    // User picked 'local' from dropdown;
    $auth_method = 1;
  } else {
    $auth_method = read_config_option('auth_method');
  }

Looking into lib/auth.php and auth_get_username() if I set the realm here to 2 it fixes the issue.

  if ($auth_method == 2) {
    $username = get_basic_auth_username();

    /* Get the Web Basic Auth username and set action so we login right away */
    set_request_var('action', 'login');
    set_request_var('realm', 2);

  } elseif (get_nfilter_request_var('action') == 'login') {
    $username = get_nfilter_request_var('login_username');
  } else {
    $username = '';

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationAuthentication related issue/featurebugUndesired behaviourconfirmedBug is confirm by dev teamresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions