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

Add support for pre existing Active Directory user #5988

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

michalpristas
Copy link
Contributor

@michalpristas michalpristas commented Nov 11, 2024

Waiting on custom windows image for testing with AD e2e.

New flags are introduced

  • user
  • group
  • password (windows only)

These flags are taken into account only when --unprivileged is used.

New user is added same permissions as elastic-agent user when created in order to be able to log on as a service (otherwise agent won't start)

Custom user won't be created and needs to be present

@michalpristas michalpristas added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-8.x Automated backport to the 8.x branch with mergify labels Nov 11, 2024
@michalpristas michalpristas self-assigned this Nov 11, 2024

flagInstallADUser = "ad-user"
flagInstallADGroup = "ad-group"
flagInstallADPass = "ad-password"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why make this a specific Windows feature? Wouldn't it be better to just allow user and group for all platforms? password is only needed for Windows.

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 agree, let's see if i can squeeze this in as this is planned for 8.17. if not i can do it iteratively

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added support for mac and linux, tested on both including switch from privileged to unprivileged.
tests TBD still

internal/pkg/agent/cmd/install.go Outdated Show resolved Hide resolved

if (customUser != "" || customPass != "") &&
(customUser == "" || customPass == "") {
return fmt.Errorf("error installing package: all Active Directory parameters must be provided")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? I think this could work by just providing say the user, then still allow the group to be created.

Or maybe you want to use the default user and password, but you want to just set the password with --password?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah but we need to be vocal about that and raise a warning that we are adding user somewhere or creating group that existing user will be part of

internal/pkg/agent/cmd/unprivileged.go Outdated Show resolved Hide resolved

if (customUser != "" || customPass != "") &&
(customUser == "" || customPass == "") {
return fmt.Errorf("error installing package: all Active Directory parameters must be provided")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

if username == "" {
// not installed with --unprivileged; nothing to do
return []serviceOpt{}, nil
}

if password != "" {
// existing user
return []serviceOpt{withUserGroup(username, groupName), withPassword(password)}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point the username must either have .\ at the start or the DOMAIN NAME like AD\username-in-ad. You are going to need to handle username having AD\ or not having .\ in the name. Otherwise the service will not start.

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
6.5% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants