Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31574 Add option in Dali LDAP support to ignore default file user #18503

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

kenrowland
Copy link
Contributor

@kenrowland kenrowland commented Apr 5, 2024

Added option to disable use of default user.
Deny access if no user provided and default user is not defined.
Do not automatically set user to authenticated.

Signed-Off-By: Kenneth Rowland [email protected]

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

@kenrowland kenrowland requested a review from jakesmith April 5, 2024 18:04
Copy link

github-actions bot commented Apr 5, 2024

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-31574

Jirabot Action Result:
Workflow Transition: Merge Pending
Updated PR
Assigning user: [email protected]

logNullUser(nullptr);
}

Owned<ISecUser> user = ldapsecurity->createUser(username);
user->setAuthenticateStatus(AS_AUTHENTICATED);
user->credentials().setPassword(password);
// user->setAuthenticateStatus(AS_AUTHENTICATED); let normal user authentication take place
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be changed.
It was deliberate to treat calls to Dali getPermissions as from a trusted user.
See : https://hpccsystems.atlassian.net/browse/HPCC-22415

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made an update that sets a passed in user as authenticated, but forces authentication for the default user. Otherwise any user/pw combination would have access in these cases.

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@kenrowland - looks good, but the user->setAuthenticateStatus(AS_AUTHENTICATED) was deliberate/shouldn't be changed in this PR.

@kenrowland kenrowland requested a review from jakesmith April 9, 2024 12:56
username.append(filesdefaultuser);
decrypt(password, filesdefaultpassword);
OWARNLOG("Missing credentials, injecting deprecated filesdefaultuser for request %s %s", key, nullText(obj));
OWARNLOG("Missing credentials, injecting deprecated filesdefaultuser (%s) for request %s %s", filesdefaultuser.str(), key,
nullText(obj));
logNullUser(nullptr);
Copy link
Member

Choose a reason for hiding this comment

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

minor: should this be above the if (disabledFileDefaultUser) so still useful when option on?

Also, I think it is already called before each call to this function in 1 context (in getPermissionsLDAP), that call should prob. be removed and just have 1 here. Not that it will make much difference as it only logs once per minute anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the logNullUser above the disable check. It would continue to be a good idea to have the information while we are analyzing each case. I did see it's called before this method is called as well. I am going assess what logging is best and make appropriate changes. Right now, more is probably better, and at only once per minute we should be OK until those changes are made.

@jakesmith jakesmith dismissed their stale review April 11, 2024 15:29

changes made

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@kenrowland - 1 minor comment, but looks good.

Added option to disable use of default user.
Deny access if no user provided and default user is not defined.
Do not automatically set user to authenticated.

Signed-Off-By: Kenneth Rowland [email protected]
@jakesmith
Copy link
Member

@kenrowland - please squash

@kenrowland
Copy link
Contributor Author

@ghalliday Squashed and ready for merge.

@@ -115,29 +117,36 @@ class CDaliLdapConnection: implements IDaliLdapConnection, public CInterface
return SecAccess_Full;


Owned<ISecUser> user;
StringBuffer username;
StringBuffer password;
if (udesc)
{
udesc->getUserName(username);
udesc->getPassword(password);
Copy link
Member

Choose a reason for hiding this comment

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

minor: password is not used by the rest of the function.

Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

@kenrowland one question

OWARNLOG("Missing credentials, injecting deprecated filesdefaultuser (%s) for request %s %s", filesdefaultuser.str(), key,
nullText(obj));
user.setown(ldapsecurity->createUser(username));
user->credentials().setPassword(password); // Force authentication of default user when used
Copy link
Member

Choose a reason for hiding this comment

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

Is this really needed? What is it protecting against? The downside of using it is that the password needs to be included in the helm configuration - which is not secure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default files user is not currently included in our helm charts, so both the username and password are empty.

@kenrowland
Copy link
Contributor Author

kenrowland commented Apr 18, 2024

This change has the implication of essentially forcing containerized deployments to always provide a user. Currently, the default user is not included in our helm charts which results in an empty username. Since that user for all intents and purposes has no permissions granted, access falls back to default file permissions. The TFE cluster was operating with a setting that allowed all access to any authenticated user. Since the user was marked as authenticated (the empty user) all scope requests were granted. IMO this is clearly not how it should operate.

This change denies access if no user is provided and either no default user is defined or the flag disabling this support is set.

W/o changes to fix all null users or adding the default user to the helm chart, once this is merged, access requests w/o a user will be denied.

@ghalliday ghalliday merged commit 21ba84c into hpcc-systems:candidate-9.6.x Apr 18, 2024
49 of 52 checks passed
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.

3 participants