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

Configurable persistence of friendly name to KV #7572

Merged
merged 7 commits into from
Apr 1, 2024

Conversation

eladlachmi
Copy link
Contributor

Closes #7562

Change Description

Background

Please see the linked issue for context.

New Feature

This PR adds two new configuration flags with a default value of false:

  1. cookie_auth_verification.persist_friendly_name - SAML-based auth API
  2. oidc.persist_friendly_name - OIDC-based auth API

When this flag is set to true, the friendly name claim pointed to by friendly_name_claim_name is saved with the user's record in the KV store. Each of the flags is only relevant to its respective authentication method.

Before:
Screenshot 2024-03-18 at 13 06 17

After:
after-screenshot
Note: domain prefix intentionally removed.

Testing Details

Both positive and negative tests were done manually.

Breaking Change?

None.

@eladlachmi eladlachmi self-assigned this Mar 18, 2024
@eladlachmi eladlachmi added include-changelog PR description should be included in next release changelog feature labels Mar 18, 2024
@eladlachmi eladlachmi requested a review from a team March 18, 2024 11:32
Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

10 passed

Copy link

github-actions bot commented Mar 18, 2024

♻️ PR Preview 061bf05 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

@eladlachmi
Copy link
Contributor Author

@Isan-Rivkin, I've refactored the implementation to align it with the new design. I would appreciate your re-review. Thanks! 🙏🏻

Copy link
Contributor

@Isan-Rivkin Isan-Rivkin left a comment

Choose a reason for hiding this comment

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

minor comments :)

put:
tags:
- auth
operationId: updateFriendlyName
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we align both the swagger and the auth service to have the same name?
e.g updateUserFriendlyName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -101,11 +101,13 @@ This reference uses `.` to denote the nesting of values.
* `auth.cookie_auth_verification.default_initial_groups` (string[] : [])` - By default, users will be assigned to these groups
* `auth.cookie_auth_verification.initial_groups_claim_name` `(string[] : [])` - Use this claim from the ID token to provide the initial group for new users. This will take priority if `auth.cookie_auth_verification.default_initial_groups` is also set.
* `auth.cookie_auth_verification.friendly_name_claim_name` `(string[] : )` - If specified, the value from the claim with this name will be used as the user's display name.
* `auth.cookie_auth_verification.persist_friendly_name` `(string : false)` - If set to `true`, the friendly name is persisted to the KV store and can be displayed in the user list. This is meant to be used in conjunction with `auth.oidc.friendly_name_claim_name`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `auth.cookie_auth_verification.persist_friendly_name` `(string : false)` - If set to `true`, the friendly name is persisted to the KV store and can be displayed in the user list. This is meant to be used in conjunction with `auth.oidc.friendly_name_claim_name`.
* `auth.cookie_auth_verification.persist_friendly_name` `(string : false)` - If set to `true`, the friendly name is persisted to the KV store and can be displayed in the user list. This is meant to be used in conjunction with `auth.cookie_auth_verification.friendly_name_claim_name`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

docs/reference/security/authentication.md Show resolved Hide resolved
Comment on lines 197 to 208
func enhanceWithFriendlyName(ctx context.Context, user *model.User, friendlyName string, persistFriendlyName bool, authService auth.Service, logger logging.Logger) *model.User {
if friendlyName != "" {
user.FriendlyName = &friendlyName
if persistFriendlyName && swag.StringValue(user.FriendlyName) != friendlyName {
err := authService.UpdateUserFriendlyName(ctx, user.Username, friendlyName)
if err != nil {
logger.WithError(err).Error("update user friendly name")
}
}
}
return user
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func enhanceWithFriendlyName(ctx context.Context, user *model.User, friendlyName string, persistFriendlyName bool, authService auth.Service, logger logging.Logger) *model.User {
if friendlyName != "" {
user.FriendlyName = &friendlyName
if persistFriendlyName && swag.StringValue(user.FriendlyName) != friendlyName {
err := authService.UpdateUserFriendlyName(ctx, user.Username, friendlyName)
if err != nil {
logger.WithError(err).Error("update user friendly name")
}
}
}
return user
}
func enhanceWithFriendlyName(ctx context.Context, user *model.User, friendlyName string, persistFriendlyName bool, authService auth.Service, logger logging.Logger) *model.User {
if swag.StringValue(user.FriendlyName) != friendlyName {
user.FriendlyName = swag.String(friendlyName)
if persistFriendlyName {
if err := authService.UpdateUserFriendlyName(ctx, user.Username, friendlyName); err != nil {
logger.WithError(err).Error("failed to update user friendly name")
}
}
}
return user
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@Isan-Rivkin Isan-Rivkin left a comment

Choose a reason for hiding this comment

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

LGTM!

@eladlachmi eladlachmi merged commit ac07c1c into master Apr 1, 2024
38 checks passed
@eladlachmi eladlachmi deleted the 7562-friendly-name-persistence branch April 1, 2024 09:50
emulatorchen pushed a commit to emulatorchen/lakeFS that referenced this pull request May 27, 2024
* Configurable persistence of friendly name to KV
* Update docs and sample config with new property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow storing of friendly_name in KV when integrating with external auth API
2 participants