feat: sync job title and department user attributes - #28
Open
c1-squire-dev[bot] wants to merge 1 commit into
Open
feat: sync job title and department user attributes#28c1-squire-dev[bot] wants to merge 1 commit into
c1-squire-dev[bot] wants to merge 1 commit into
Conversation
OneLogin exposes `title` and `department` on the user object, but the connector neither requested them from the API nor surfaced them on the synced user. Downstream policies and automations that key off job title or department therefore had nothing to match on. - Add `Title` and `Department` to the `onelogin.User` model. - Add `title` and `department` to `UserFields` so the users list endpoint actually returns them (that endpoint only returns requested fields). - Populate `job_title` and `department` in the user trait profile, using the profile key names other ConductorOne connectors already use. Both are trimmed and omitted when blank, matching the existing treatment of the optional manager fields. - Take `*onelogin.User` in `buildUserProfile` instead of seven positional scalars, so adding fields can't silently swap arguments. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes EPD-2982.
Summary
OneLogin exposes
titleanddepartmenton its user object, but the connector never asked the API for them and never surfaced them on the synced user. Policies and automations in C1 that want to key off job title or department had nothing to match on.This change plumbs both attributes through the user sync:
pkg/onelogin/models.go— addTitleandDepartmentto theUsermodel.pkg/onelogin/request.go— addtitleanddepartmenttoUserFields. The client always sends afieldsquery param on/api/2/users, and that endpoint returns only the named fields, so the list response would otherwise omit both.userResourceType.Listdiscards the listed object and rebuilds each user fromGetUserByID, which sends nofieldsfilter and already returns the full record. The synced profile is populated from that by-ID response. Keeping the two response shapes aligned avoids a trap if the per-user refetch is ever dropped.pkg/connector/user.go— populatejob_titleanddepartmentin the user trait profile.job_title/departmentare the profile key names already used by sibling connectors (baton-jumpcloud, baton-paylocity, baton-percipio), so the attributes land under a consistent name in C1.manager_user_id/manager_emailkeys are handled — downstream consumers don't have to special-case empty strings.buildUserProfilenow takes*onelogin.Userinstead of seven positional scalars. The old signature was threestringparams in a row and growing it further is exactly the swapped-argument hazard called out inCLAUDE.md. It has one caller, so the refactor is local.No behavior change for users whose OneLogin record leaves title or department unset.
Testing
Added
pkg/connector/user_test.go(new) and extendedpkg/onelogin/request_test.go:job_title/departmentare populated in the profile when present.login,user_id,first_name,last_name, manager fields) still populate as before — regression cover for the signature refactor.v2.Resourceprofile carries both attributes end-to-end throughparseIntoUserResource.UserFieldsincludestitleanddepartmentalongside the pre-existing fields.UserJSON decoding handles both present and absenttitle/department.10/10 tests pass.
go vet ./...clean.golangci-lint runreports no new findings — the 8 remainingSA1019deprecation warnings (WithUserProfile,WithStatus,WithAppProfile,WithGroupProfile,WithRoleProfile) are all pre-existing onmainand untouched here.Caveats / follow-ups
title/departmentunder those exact JSON keys for the tenant's schema.SA1019deprecations (trait-level profile/status options moving to resource-levelWithResourceProfile/WithResourceStatus) are a separate cleanup — deliberately left alone to keep this diff scoped.company,division, andcustom_attributes. Not included, since the request was specifically job title and department.UserFieldsstill omitsmanager_user_id, which is whyListrefetches every user viaGetUserByID— an N+1 per sync page. Adding it toUserFieldswould likely let the refetch go away entirely. Out of scope here, but worth a follow-up.Live Preview
This connector is a CLI binary with no web surface, so there is nothing to preview in-browser. For completeness, the environment's static endpoint is here (serves nothing relevant to this change). Reviewers should verify via
go test ./pkg/...or abaton-oneloginsync against a test tenant.