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 option to provide custom user transformer #1103

Merged
merged 7 commits into from
Sep 27, 2023
Merged

Add option to provide custom user transformer #1103

merged 7 commits into from
Sep 27, 2023

Conversation

ianaktr
Copy link
Contributor

@ianaktr ianaktr commented Sep 4, 2023

This PR adds an option to provide a custom user transformer for okta users in user and org providers. It is a similar feature that LDAP has. If the transformer is provided it will be used instead of userEntityFromOktaUser.

In our use case, we want to fill some of the fields of the user entity which isn't possible to do now. For example, profile.picture or metadata.description.

Something similar was discussed in this issue #900

If this approach is accepted, I can also do that for groups.

✔️ Checklist

  • Added tests for new functionality and regression tests for bug fixes
  • Added changeset (run yarn changeset in the root)
  • Screenshots of before and after attached (for UI changes)
  • Added or updated documentation (if applicable)

@ianaktr ianaktr requested a review from a team as a code owner September 4, 2023 13:54
@kissmikijr kissmikijr self-assigned this Sep 13, 2023
@kissmikijr
Copy link
Contributor

Fantastic thank you for this. It looks great. Would you mind adding to the groups as well?

@ianaktr
Copy link
Contributor Author

ianaktr commented Sep 14, 2023

Yes, of course! I will add this for groups as well 👍

@ianaktr
Copy link
Contributor Author

ianaktr commented Sep 15, 2023

@kissmikijr Hey! I added functionality to the groups as well and also updated the documentation. Would be nice if you could take a look once you have time. Thanks!

Comment on lines +463 to +465
metadata: expect.objectContaining({
name: 'asdfwefwefwef',
description: 'Everyone in the company',
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add the annotations to this as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I am not sure I understand. Do you mean to check annotations object in metadata? The untransformed group doesn't have any custom annotations that's why I didn't add any checks here. Only for the new profile.displayName which isn't available in the default transformer

export type OktaGroupEntityTransformer = (
group: OktaGroup,
namingStrategy: GroupNamingStrategy,
parentGroup: OktaGroup | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could make parentGroup optional so we dont need to write out the explicit undefined here

Suggested change
parentGroup: OktaGroup | undefined,
parentGroup?: OktaGroup,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Done

Copy link
Contributor

@kissmikijr kissmikijr left a comment

Choose a reason for hiding this comment

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

Thank you! Left some tiny tiny comments, otherwise it looks good!

Copy link
Contributor

@kissmikijr kissmikijr left a comment

Choose a reason for hiding this comment

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

Thank you! Let's ship it!

@kissmikijr kissmikijr merged commit bfebbbf into RoadieHQ:main Sep 27, 2023
2 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.

2 participants