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

Gitlab LDAP sync script tries to remove "bot" users from groups. #44

Open
TafkaMax opened this issue Jan 22, 2024 · 8 comments
Open

Gitlab LDAP sync script tries to remove "bot" users from groups. #44

TafkaMax opened this issue Jan 22, 2024 · 8 comments
Labels
need testing Extra testing is needed

Comments

@TafkaMax
Copy link

The Gitlab LDAP sync script tries to currently remove "bot users" that are created when adding an access_token from non-ldap groups. Maybe even from groups that are also present in LDAP.

https://gitlab.example.com/groups/<GROUPNAME>/-/settings/access_tokens

@TafkaMax
Copy link
Author

[notice] Deleting extra group members...
[info] Deleting user #132 "REDACTED" from group #1019 "REDACTED" [REDACTED].
[error] Gitlab failure: 403 Forbidden

@TafkaMax
Copy link
Author

image

When adding an access token to a group a bot user is created there. So a check is necessary to see if user is bot.

@AdamReece-WebBox
Copy link
Collaborator

AdamReece-WebBox commented Jan 25, 2024

I've not looked yet, but I suspect the users API will be able to reveal if a user is a bot. We could then exclude bot users from deletions.

(I noticed this happening at our corporate Gitlab too, though I've only ever needed to run the tool once here so far.)

@TafkaMax TafkaMax changed the title Gitlab LDAP sync script tries to remove "bot users" from non-ldap groups. Gitlab LDAP sync script tries to remove "bot" users from groups. Jan 25, 2024
@TafkaMax
Copy link
Author

Reformatted the Title. I first noticed it with groups that did not match a LDAP group name. But it is happening with all groups.

@mojibake-umd
Copy link

There is a boolean attribute called humans in the Gitlab Users API and a boolean attribute called bot for Gitlab User API

@Adambean
Copy link
Owner

Adambean commented Oct 3, 2024

According to the documentation the "bot" property is only returned when querying the API for a single user, not in the response when querying for multiple users. I'll check if that's true.

Adambean added a commit that referenced this issue Oct 3, 2024
@Adambean
Copy link
Owner

Adambean commented Oct 3, 2024

I've added a branch issue/19-script-tries-to-remove-bots-from-groups you can switch to to see if this works for you. (Dry run first of course.)

@Adambean Adambean added the need testing Extra testing is needed label Oct 3, 2024
@mojibake-umd
Copy link

@Adambean without_project_bots default is false...
curl -s --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" "https://gitlab.example.com/api/v4/users?without_project_bots=true"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need testing Extra testing is needed
Projects
None yet
Development

No branches or pull requests

4 participants