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

feat(ldap): sync additional properties to profile and SAB #45512

Merged
merged 1 commit into from
May 30, 2024

Conversation

st3iny
Copy link
Member

@st3iny st3iny commented May 26, 2024

Summary

This PR merges #41793 and #39592. I added neccessary frontend code so that users can change their date of births and adjust the scope in case they don't want it to be synced to the SAB.

I also removed the anniversary date after having a discussion with our designers. We are required to take the detour via the profile page to allow users to set the scope. Considering the broad spectrum that Nextcloud is used in, it doesn't make sense to have an anniversary date on the profile.

Synced from LDAP to profile:

  • Date of birth

Synced from LDAP to SAB (via the profile):

  • Biography
  • Date of birth

Original code by Jake Nabasny (GitHub: @slapcat). Your contribution is highly valued ❤️

Screenshots

Synced contact in SAB

Bildschirmfoto_20240526_105524

Date of birth in personal settings

Bildschirmfoto_20240526_110044

LDAP wizard (advanced tab)

Bildschirmfoto_20240526_105358

TODO

  • Tests (probably)

Checklist

@st3iny st3iny added enhancement 2. developing Work in progress feature: ldap feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.) feature: caldav Related to CalDAV internals labels May 26, 2024
@st3iny st3iny added this to the Nextcloud 30 milestone May 26, 2024
@st3iny st3iny self-assigned this May 26, 2024
@st3iny
Copy link
Member Author

st3iny commented May 27, 2024

Pending documentation at nextcloud/documentation#11323 (although it has to be adjusted to the removed anniversary field).

@st3iny st3iny force-pushed the feat/ldap/additional-attributes branch from 5463fdc to 8855b2b Compare May 27, 2024 12:26
@st3iny st3iny marked this pull request as ready for review May 27, 2024 12:27
@st3iny st3iny added 3. to review Waiting for reviews and removed 2. developing Work in progress labels May 27, 2024
@st3iny st3iny requested a review from come-nc May 27, 2024 12:28
Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

What kind of LDAP attribute was this tested with?
I’m afraid it won’t work with LDAP date format which is quite specific and not supported by PHP out-of-the-box.

@come-nc
Copy link
Contributor

come-nc commented May 27, 2024

@st3iny
Copy link
Member Author

st3iny commented May 27, 2024

Côme made a good point. There is no standardized birthdate field on LDAP. However, some implementations use the standardized generalized date format while others user the YYYY-MM-DD format.

So we need a parser for the LDAP format and fallback to the date constructor.

@slapcat
Copy link
Contributor

slapcat commented May 27, 2024

@come-nc I tested it with an attribute using the same Generalized Time syntax that you linked and it worked fine for both showing the date in the frontend and generating it on contact cards for the cardDAV server. Here is the full attribute type I use:

olcAttributeTypes: {0}( 1.3.6.1.4.1.59010.1.1 NAME 'birthDate' DESC 'Birthday'
  EQUALITY generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX 1
 .3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )

@come-nc
Copy link
Contributor

come-nc commented May 28, 2024

@come-nc I tested it with an attribute using the same Generalized Time syntax that you linked and it worked fine for both showing the date in the frontend and generating it on contact cards for the cardDAV server. Here is the full attribute type I use:

olcAttributeTypes: {0}( 1.3.6.1.4.1.59010.1.1 NAME 'birthDate' DESC 'Birthday'
  EQUALITY generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX 1
 .3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )

Using the two examples from the RFC the second one crashes DateTime constructor:
https://3v4l.org/uSuTs

Try setting your attribute to "199412160532-0500" which is a valid value from the RFC.

@st3iny
Copy link
Member Author

st3iny commented May 28, 2024

I added a rudimentary parser, that just uses the first 8 characters from the LDAP generalized syntax and tries to parse YYYYMMDD or YYYY-MM-DD otherwise. Is that sufficient?

I also tested it with a real LDAP generalized time attribute on my local dev instance. Of course, I also added some unit test for the parser method ...

@st3iny st3iny requested a review from come-nc May 28, 2024 11:03
@st3iny st3iny force-pushed the feat/ldap/additional-attributes branch from 7d8a467 to e1b5855 Compare May 28, 2024 11:41
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Looks good

some bundle updates are suspicious. e.g. dist/weather_status-weather-status.js changed

apps/user_ldap/lib/Service/BirthdateParserService.php Outdated Show resolved Hide resolved
Synced from LDAP to profile:
- Date of birth

Synced from LDAP to SAB (via the profile):
- Biography
- Date of birth

Original code by Jake Nabasny (GitHub: @slapcat)

Co-authored-by: Jake Nabasny <jake@nabasny.com>
Co-authored-by: Richard Steinmetz <richard@steinmetz.cloud>
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny st3iny force-pushed the feat/ldap/additional-attributes branch from abef449 to f863290 Compare May 30, 2024 10:01
@st3iny st3iny enabled auto-merge May 30, 2024 10:03
@st3iny st3iny merged commit 31b0a44 into master May 30, 2024
155 checks passed
@st3iny st3iny deleted the feat/ldap/additional-attributes branch May 30, 2024 10:39
@szaimen
Copy link
Contributor

szaimen commented May 30, 2024

🎉🎉🎉🎉🎉

/**
* @since 30.0.0
*/
public const PROPERTY_BIRTHDATE = 'birthdate';
Copy link
Member

@nickvergessen nickvergessen Jul 18, 2024

Choose a reason for hiding this comment

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

@nickvergessen nickvergessen added the pending documentation This pull request needs an associated documentation update label Jul 18, 2024
@blizzz blizzz mentioned this pull request Jul 24, 2024
@aurisnoctis
Copy link

Will this change allow people to add their birthday to their profile even if the nextcloud server uses not LDAP but the default database?

@st3iny
Copy link
Member Author

st3iny commented Aug 22, 2024

@aurisnoctis Yes, it does work without LDAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement feature: caldav Related to CalDAV internals feature: ldap feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.) pending documentation This pull request needs an associated documentation update
Projects
Development

Successfully merging this pull request may close these issues.

More LDAP User Profile Attributes
7 participants