zibasec / django-saml2-pro-auth

SAML2 authentication backend for Django wrapping OneLogin's python-saml package https://github.com/onelogin/python3-saml
MIT License
30 stars 28 forks source link

add default attribute value when strict is disabled #25

Closed HeavenSleep closed 6 years ago

HeavenSleep commented 6 years ago

To avoid model modification or creation of a custom model to handle default value, I added a simple option to the attribute map dictionary when SAML_USERS_STRICT_MAPPING = False allowing something like:

SAML_USERS_SYNC_ATTRIBUTES = True
SAML_USERS_STRICT_MAPPING = False
SAML_USERS_MAP = [{
    "MyProvider" : {
      "email": dict(key="email", index=0),
      "username": dict(key="username", index=0),
      "is_superuser": dict(key="is_superuser", index=0, default=False),
      "is_staff": dict(key="is_staff", index=0, default=False)
    }
}]
juliedavila commented 6 years ago

I would like to see an error appear in the event that strict mapping is set to True AND a default value is specified. Let's do that and make the docs modification and this should be good to go.

juliedavila commented 6 years ago

Thanks for the contribution!

HeavenSleep commented 6 years ago

Thanks and you're welcome!

Also, I would like to know when the pip version could be updated to reflect this change so I can use it in my app instead of manually patching it?

juliedavila commented 6 years ago

I just published it under 0.0.8