Skip to content

Set user attributes based on the IdP in use, not an attribute #158

@oliwarner

Description

@oliwarner

I've got a multi-IdP setup, with a custom loader, that varies based on the Company (pulled from the URL) you're attempting to log into. That side of the equation seems to work well.

The problem is new users. The User (custom model) instance gets created. And can be used, but I need to link that to the Company. There's a company FK (so company_id in raw terms) field.

This ID is not communicated from the IdP. And that's by-design. allowing the IdP to set the company would be a security hole. I need some way to tie new users on a given IdP to their company.

I have one config per company. Ideally I'd be able to set something that poisoned the attributes, or something that explicitly got used in backends._get_or_create_saml2_user. A config-static dictionary eg NEW_USER_DEFAULTS, seems reasonable but I can't figure out how to access the IdP config in use from within backends._get_or_create_saml2_user. That data doesn't appear to exist by that point.

I've also considered hooking djangosaml2.signals.pre_user_save but again, I don't think I have access to the saml config in use by that point.

Can somebody point me in the right direction?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions