django_scim


Namedjango_scim JSON
Version 0.6.97 PyPI version JSON
download
home_pagehttps://bitbucket.org/atlassian/django_scim
SummaryA partial implementation of the SCIM 2.0 provider specification for use with Django.
upload_time2023-09-13 22:00:22
maintainerNone
docs_urlNone
authorErik van Zijst
requires_pythonNone
licenseMIT
keywords django scim
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Django SCIM
===========

This is a partial provider-side implementation of the SCIM 2.0 [1]_
specification for use in Django. It covers:

- Serialization of Django ``User`` objects to SCIM documents
- REST view for ``<prefix>/Users/uid``
- REST view for ``<prefix>/Users/.search``
- SCIM filter query parser covering all operators and most fields
- Limited pluggability support

Note that currently the only supported database is Postgres.


Installation
------------

::

    $ pip install django_scim

Then add the ``django_scim`` app to ``INSTALLED_APPS`` in Django's settings
file and the necessary url mappings::

    urlpatterns = patterns('',
        url(r'^/scim/v2/Users/.search/?$',
            SearchView.as_view(), name='scim-search'),
        url(r'^/scim/v2/Users/([^/]+)$', UserView.as_view(), name='scim-user'),
    )


Extensibility
-------------

By default, ``django_scim`` uses the email field on the ``User`` class. However,
if your application maintains multiple identities using custom separate
database tables, you can override ``django_scim.models.SCIMUser`` and pull that
in::

    from django_scim.models import SCIMUser as _SCIMUser

    from acme.apps.bb.models import Identity


    class SCIMUser(_SCIMUser):
        def __init__(self, user):
            super(SCIMUser, self).__init__(user)
            self.identities = (Identity.objects
                                       .filter(profile__user_id=self.user.id))

        @property
        def emails(self):
            return {i.email: i.primary for i in self.identities}


Here we keep multiple email addresses in a table that is linked to
``UserProfile``. Next, tell the views to use this class instead of the
default::

        url(r'^/scim/v2/Users/([^/]+)$', UserView.as_view(usercls=SCIMUser),
            name='scim-user'),

When your email address live in different tables, you'll also need to extend
the filter query parser to make sure they can be queried on::

    from django_scim.filter import SCIMFilterTransformer


    class AcmeSCIMTransformer(SCIMFilterTransformer):
        email = lambda *args: 'i.email'

        def join(self):
            return """
                JOIN bb_userprofile p ON p.user_id = u.id
                LEFT OUTER JOIN bb_identity i ON i.profile_id = p.id
                """

And pass it on to the view::

        url(r'^/scim/v2/Users/([^/]+)$',
            UserView.as_view(usercls=SCIMUser, parser=AcmeSCIMTransformer),
            name='scim-user'),


.. [1] http://www.simplecloud.info/

            

Raw data

            {
    "_id": null,
    "home_page": "https://bitbucket.org/atlassian/django_scim",
    "name": "django_scim",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django scim",
    "author": "Erik van Zijst",
    "author_email": "erik.van.zijst@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e4/c4/5dfd0503f2aadc87cc68ec8584922c611e7931c5ff10ee4bb5421bfa0ce8/django_scim-0.6.97.tar.gz",
    "platform": null,
    "description": "Django SCIM\n===========\n\nThis is a partial provider-side implementation of the SCIM 2.0 [1]_\nspecification for use in Django. It covers:\n\n- Serialization of Django ``User`` objects to SCIM documents\n- REST view for ``<prefix>/Users/uid``\n- REST view for ``<prefix>/Users/.search``\n- SCIM filter query parser covering all operators and most fields\n- Limited pluggability support\n\nNote that currently the only supported database is Postgres.\n\n\nInstallation\n------------\n\n::\n\n    $ pip install django_scim\n\nThen add the ``django_scim`` app to ``INSTALLED_APPS`` in Django's settings\nfile and the necessary url mappings::\n\n    urlpatterns = patterns('',\n        url(r'^/scim/v2/Users/.search/?$',\n            SearchView.as_view(), name='scim-search'),\n        url(r'^/scim/v2/Users/([^/]+)$', UserView.as_view(), name='scim-user'),\n    )\n\n\nExtensibility\n-------------\n\nBy default, ``django_scim`` uses the email field on the ``User`` class. However,\nif your application maintains multiple identities using custom separate\ndatabase tables, you can override ``django_scim.models.SCIMUser`` and pull that\nin::\n\n    from django_scim.models import SCIMUser as _SCIMUser\n\n    from acme.apps.bb.models import Identity\n\n\n    class SCIMUser(_SCIMUser):\n        def __init__(self, user):\n            super(SCIMUser, self).__init__(user)\n            self.identities = (Identity.objects\n                                       .filter(profile__user_id=self.user.id))\n\n        @property\n        def emails(self):\n            return {i.email: i.primary for i in self.identities}\n\n\nHere we keep multiple email addresses in a table that is linked to\n``UserProfile``. Next, tell the views to use this class instead of the\ndefault::\n\n        url(r'^/scim/v2/Users/([^/]+)$', UserView.as_view(usercls=SCIMUser),\n            name='scim-user'),\n\nWhen your email address live in different tables, you'll also need to extend\nthe filter query parser to make sure they can be queried on::\n\n    from django_scim.filter import SCIMFilterTransformer\n\n\n    class AcmeSCIMTransformer(SCIMFilterTransformer):\n        email = lambda *args: 'i.email'\n\n        def join(self):\n            return \"\"\"\n                JOIN bb_userprofile p ON p.user_id = u.id\n                LEFT OUTER JOIN bb_identity i ON i.profile_id = p.id\n                \"\"\"\n\nAnd pass it on to the view::\n\n        url(r'^/scim/v2/Users/([^/]+)$',\n            UserView.as_view(usercls=SCIMUser, parser=AcmeSCIMTransformer),\n            name='scim-user'),\n\n\n.. [1] http://www.simplecloud.info/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A partial implementation of the SCIM 2.0 provider specification for use with Django.",
    "version": "0.6.97",
    "project_urls": {
        "Download": "https://bitbucket.org/atlassian/django_scim/downloads/django_scim-0.6.tar.gz",
        "Homepage": "https://bitbucket.org/atlassian/django_scim"
    },
    "split_keywords": [
        "django",
        "scim"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4c45dfd0503f2aadc87cc68ec8584922c611e7931c5ff10ee4bb5421bfa0ce8",
                "md5": "ba71dfb0feeb6e2dcdd23bc40300fb2b",
                "sha256": "0d5e937222636e9abbc541dfed42857b00dfdf4a5b63781b28f47619e38e0e15"
            },
            "downloads": -1,
            "filename": "django_scim-0.6.97.tar.gz",
            "has_sig": false,
            "md5_digest": "ba71dfb0feeb6e2dcdd23bc40300fb2b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7620,
            "upload_time": "2023-09-13T22:00:22",
            "upload_time_iso_8601": "2023-09-13T22:00:22.048009Z",
            "url": "https://files.pythonhosted.org/packages/e4/c4/5dfd0503f2aadc87cc68ec8584922c611e7931c5ff10ee4bb5421bfa0ce8/django_scim-0.6.97.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-13 22:00:22",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "atlassian",
    "bitbucket_project": "django_scim",
    "lcname": "django_scim"
}
        
Elapsed time: 0.19071s