Giter Site home page Giter Site logo

mockdjangosaml2's People

Contributors

charn avatar chornsby avatar darbula avatar jaywink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mockdjangosaml2's Issues

Accessing `hrEduPersonOIB` from `request.user`

The authentication passes and I want to access the data defined in the mockdjangosaml2 settings. The data I'm interested in is hrEduPersonOIB.

I've tried adding th following:

SAML_ATTRIBUTE_MAPPING = {
   ...
    'hrEduPersonOIB': ('id',)
}

with the idea that that would allow me to access the data defined for hrEduPersonOIB through request.user.id. once the authentication passes.

However, i got an IntegrityError stating column username is not unique.
The fail happens here:

#djangosaml2.backends.py
---> 87                 user = self.configure_user(user, attributes, attribute_mapping)

ipdb> user
<User: employee@aai-test.hr>

ipdb> attributes
{'givenName': ['Employee'], 'hrEduPersonPrimaryAffiliation': ['djelatnik'], 'cn': ['Employee Surname'], 'hrEduPersonHomeOrg': ['aai-test.hr'], 'mail': ['[email protected]'], 'hrEduPersonOIB': ['12345678902'], 'hrEduPersonUniqueID': ['[email protected]'], 'sn': ['Surname']}

ipdb> attribute_mapping
{'mail': ('email',), 'givenName': ('first_name',), 'hrEduPersonUniqueID': ('username',), 'sn': ('last_name',), 'hrEduPersonOIB': ('id',)}

Further tracedown lead to the problem here:

    176         if user_modified or signal_modified or force_save:
--> 177             user.save()

So far I've concluded the following:

  1. The user is first created in the database solely with its username
  2. Updating the other fields is a separate step

I believe that the cause of the problem is that fields are not updated because the id is changed so the already created user is perceived as a new user. However the new user can't be created because the username field in the database has to be unique.

Feel free to ignore all the diagnosis above if there is a clean way of accessing hrEduPersonOIB from request.user.

Why set the MOCK_SAML2_USERS with the getattr default value?

In the sample in settings.py you're importing the settings module into itself and using getattr the default value of getattr to set the value of MOCK_SAML2_USERS.

from django.conf import settings
MOCK_SAML2_USERS = getattr(settings, 'MOCK_SAML2_USERS', {...DEFAULT ...}   

Why not just set the MOCK_SAML2_USERS?

MOCK_SAML2_USERS = {...DEFAULT...}

mockdjangosaml2 not authenticating

I am trying to authenticate with the default user:

However, it doesnt't authenticate, 403 Forbidden is returned.

I have traced the problem to the djangosaml2.backends.Saml2Backend. I'm not sure if you went into its internals. The failure happens here:

     50         for saml_attr, django_fields in attribute_mapping.items():
---> 51             if (django_user_main_attribute in django_fields
     52                 and saml_attr in attributes):

It fails on the saml_attr in attributes part. Here are the values at runtime:

ipdb> saml_attr
'uid'
ipdb> attributes
{'givenName': ['Employee'], 'hrEduPersonPrimaryAffiliation': ['djelatnik'], 'cn': ['Employee Surname'], 'hrEduPersonHomeOrg': ['aai-test.hr'], 'mail': ['[email protected]'], 'hrEduPersonOIB': ['12345678902'], 'hrEduPersonUniqueID': ['[email protected]'], 'sn': ['Surname']}

From what it seems,
there is either supposed to be a uid key in attributes, or uid should be named differently. I beleive that the origins of uid are from:

#mockdjangosaml2/views.py
71    attribute_mapping = get_custom_setting(
            'SAML_ATTRIBUTE_MAPPING', {'uid': ('username', )})

Logger output?

What is the location of the output from the logger started here:

#/mockdjangosaml2/views.py
....
logger = logging.getLogger('djangosaml2')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.