Pass on SAML Attributes when registering an external account

Created on 8 September 2022, almost 2 years ago
Updated 25 January 2024, 5 months ago

Problem/Motivation

It would be nice to have the SAML Attributes available in the ExternalAuth Register event. This makes it possible to alter some data on the account based on the SAML Attributes.

Proposed resolution

Pass on SAML Attributes to the ExternalAuth::register method.

✨ Feature request
Status

Closed: works as designed

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States John Franklin

    +1 this patch.

    • roderik β†’ committed 069c02c5 on 8.x-3.x
      Issue #3308562: add more documentation about SamlauthEvents::USER_SYNC...
  • πŸ‡³πŸ‡±Netherlands roderik Amsterdam,NL / Budapest,HU

    I prefer forcing you to use the SamlauthEvents::USER_SYNC event. Unless you can convince me you really need the ExternalAuth Register event.

    Advantages of SamlauthEvents::USER_SYNC:

    • User accounts are saved only once / if you somehow see strange data in your attributes and you want to deny the user access, you can throw an exception without having your users polluted. (If you do this from the the ExternalAuth Register event, a user is already saved with partial data.)
    • You have one place to do things with SAML attributes, and can use the same code (if applicable) regardless whether the user is newly registered.

    In exchange for the above two points, you must:

    • not save the account yourself, but call $event->markAccountChanged(), to prevent needless saves.
    • add a if($event->getAccount()->isNew() if you want to act only on newly registered users.

    I've hopefully improved documentation to make clearer that this is also meant to be used during user registration.

    I'll close this after a while if no feedback received.

  • πŸ‡³πŸ‡±Netherlands roderik Amsterdam,NL / Budapest,HU
  • Status changed to Closed: works as designed 6 months ago
  • πŸ‡³πŸ‡±Netherlands roderik Amsterdam,NL / Budapest,HU
Production build 0.69.0 2024